Compare commits
No commits in common. "5b045b322b2f79208146c4e84ff734bd5806b601" and "ac9b8feb33db4d9ab9c7901e73d92d89a9b533d0" have entirely different histories.
5b045b322b
...
ac9b8feb33
|
@ -48,11 +48,4 @@ public class ProjectController {
|
|||
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 Boolean IsCompleted;
|
||||
@TableLogic
|
||||
private Boolean isDeleted;
|
||||
private Boolean deleted;
|
||||
private Integer projectCreator;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
|||
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||
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 com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -20,7 +19,7 @@ public interface IProjectService extends IService<Project> {
|
|||
|
||||
Page<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
|
||||
|
||||
Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException;
|
||||
Boolean setProjectCompleted(String token, Project project) throws TokenException;
|
||||
|
||||
Boolean makeANewProject(Project project) throws TokenException;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
|||
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||
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.mapper.ProjectMapper;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||
|
@ -16,9 +15,7 @@ import io.swagger.models.auth.In;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 阳勇权
|
||||
|
@ -40,27 +37,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|||
Integer pageSize,
|
||||
Map<String, Object> params
|
||||
) throws TokenException {
|
||||
Integer staffId = 2;
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
|
||||
IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
|
||||
return (Page<ResultProject>) userPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException {
|
||||
public Boolean setProjectCompleted(String token, Project project) throws TokenException {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
Project project=new Project();
|
||||
project.setProjectId(projectId);
|
||||
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
||||
if(targetProject==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("操作失败");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue