Compare commits
2 Commits
ac9b8feb33
...
5b045b322b
Author | SHA1 | Date |
---|---|---|
白封羽 | 5b045b322b | |
白封羽 | 592cca7f6a |
|
@ -48,4 +48,11 @@ public class ProjectController {
|
||||||
return ResponseMap.ofSuccess("获得参与项目总数", res);
|
return ResponseMap.ofSuccess("获得参与项目总数", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@PostMapping("/complete")
|
||||||
|
public ResponseMap completeProject(@RequestHeader("Token") String token,@RequestBody Map<String,Object> map){
|
||||||
|
Integer targetProjectId=(Integer)map.get("projectId");
|
||||||
|
projectServiceImpl.setProjectCompleted(token, targetProjectId);
|
||||||
|
return ResponseMap.ofSuccess("操作成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,6 @@ public class Project {
|
||||||
private String projectDescription;
|
private String projectDescription;
|
||||||
private Boolean IsCompleted;
|
private Boolean IsCompleted;
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private Boolean deleted;
|
private Boolean isDeleted;
|
||||||
private Integer projectCreator;
|
private Integer projectCreator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -19,7 +20,7 @@ public interface IProjectService extends IService<Project> {
|
||||||
|
|
||||||
Page<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
|
Page<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
|
||||||
|
|
||||||
Boolean setProjectCompleted(String token, Project project) throws TokenException;
|
Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException;
|
||||||
|
|
||||||
Boolean makeANewProject(Project project) throws TokenException;
|
Boolean makeANewProject(Project project) throws TokenException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
|
@ -15,7 +16,9 @@ import io.swagger.models.auth.In;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 阳勇权
|
* @author 阳勇权
|
||||||
|
@ -37,18 +40,27 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
Integer pageSize,
|
Integer pageSize,
|
||||||
Map<String, Object> params
|
Map<String, Object> params
|
||||||
) throws TokenException {
|
) throws TokenException {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = 2;
|
||||||
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
|
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
|
||||||
IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
|
IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
|
||||||
return (Page<ResultProject>) userPage;
|
return (Page<ResultProject>) userPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean setProjectCompleted(String token, Project project) throws TokenException {
|
public Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
|
Project project=new Project();
|
||||||
|
project.setProjectId(projectId);
|
||||||
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
||||||
|
if(targetProject==null)
|
||||||
return null;
|
throw new BadRequestException("项目不存在");
|
||||||
|
if(!Objects.equals(staffId, targetProject.getProjectCreator()))
|
||||||
|
throw new BadRequestException("用户请求非法");
|
||||||
|
targetProject.setIsCompleted(true);
|
||||||
|
targetProject.setProjectCloseTime(LocalDate.now());
|
||||||
|
if(baseMapper.updateById(targetProject)==1)
|
||||||
|
return true;
|
||||||
|
throw new BadRequestException("操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue