Compare commits

...

2 Commits

Author SHA1 Message Date
白封羽 5b045b322b Merge remote-tracking branch 'origin/master' 2022-06-30 18:48:18 +08:00
白封羽 592cca7f6a 完成了结项功能 2022-06-30 18:48:14 +08:00
4 changed files with 26 additions and 6 deletions

View File

@ -48,4 +48,11 @@ 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("操作成功");
}
}

View File

@ -36,6 +36,6 @@ public class Project {
private String projectDescription;
private Boolean IsCompleted;
@TableLogic
private Boolean deleted;
private Boolean isDeleted;
private Integer projectCreator;
}

View File

@ -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.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;
@ -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;
Boolean setProjectCompleted(String token, Project project) throws TokenException;
Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException;
Boolean makeANewProject(Project project) throws TokenException;
}

View File

@ -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.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;
@ -15,7 +16,9 @@ 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
@ -37,18 +40,27 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
Integer pageSize,
Map<String, Object> params
) throws TokenException {
Integer staffId = TokenUtils.getStaffId(token);
Integer staffId = 2;
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, Project project) throws TokenException {
public Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException {
Integer staffId = TokenUtils.getStaffId(token);
Project project=new Project();
project.setProjectId(projectId);
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
return null;
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("操作失败");
}
@Override