diff --git a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/ProjectGroupController.java b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/ProjectGroupController.java index aa02e34..4568b70 100644 --- a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/ProjectGroupController.java +++ b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/ProjectGroupController.java @@ -8,9 +8,6 @@ import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList; import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.media.SchemaProperty; import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/TaskController.java b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/TaskController.java index 3dd7b95..1bd307c 100644 --- a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/TaskController.java +++ b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/controller/TaskController.java @@ -2,6 +2,8 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller; import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task; import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto; +import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException; +import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService; import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService; import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList; import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap; @@ -20,7 +22,8 @@ import java.util.List; public class TaskController { @Autowired private ITaskService taskService; - + @Autowired + private IProjectService projectService; @SneakyThrows @GetMapping("/{fatherId}/subtask") public ResponseList getSubTaskList( @@ -57,6 +60,8 @@ public class TaskController { @PathVariable("projectId") Integer projectId, @RequestBody Task task ) { + if(!projectService.checkOpenStatus(projectId)) + throw new BadRequestException("项目未开放"); task.setTaskProjectId(projectId); taskService.insertTask(token, task); return ResponseMap.ofSuccess("操作成功"); @@ -70,6 +75,8 @@ public class TaskController { @PathVariable("taskId") Long taskId, @RequestBody Task task ) { + if(!projectService.checkOpenStatus(projectId)) + throw new BadRequestException("项目未开放"); task.setTaskProjectId(projectId); task.setTaskId(taskId); taskService.modifyTask(token, task); @@ -83,6 +90,8 @@ public class TaskController { @PathVariable("projectId") Integer projectId, @PathVariable("taskId") Long taskId ) { + if(!projectService.checkOpenStatus(projectId)) + throw new BadRequestException("项目未开放"); taskService.deleteTaskAndSubTask(token, projectId, taskId); return ResponseMap.ofSuccess("删除成功"); } diff --git a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/IProjectService.java b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/IProjectService.java index 7915e5e..920aaec 100644 --- a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/IProjectService.java +++ b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/IProjectService.java @@ -22,4 +22,6 @@ public interface IProjectService extends IService { Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException; Boolean createProject(String token, Project project) throws BadRequestException; + + Boolean checkOpenStatus(Integer projectId); } diff --git a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/impl/ProjectServiceImpl.java b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/impl/ProjectServiceImpl.java index 439d92e..2b02783 100644 --- a/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/impl/ProjectServiceImpl.java +++ b/src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/service/impl/ProjectServiceImpl.java @@ -93,4 +93,11 @@ public class ProjectServiceImpl extends ServiceImpl impl } return false; } + + public Boolean checkOpenStatus(Integer projectId) { + if (projectId == null || projectId < 1) + return false; + Project project = baseMapper.selectOne(Wrappers.lambdaQuery().eq(Project::getProjectId, projectId)); + return project != null && !project.getCompleted(); + } }