添加了已结项项目的工作项变更操作阻止

master
白封羽 2022-07-07 12:06:00 +08:00
parent 9690fff08e
commit cf434fface
4 changed files with 19 additions and 4 deletions

View File

@ -8,9 +8,6 @@ import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap; import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Parameter; 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 lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;

View File

@ -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.Task;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto; 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.service.ITaskService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList; import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap; import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
@ -20,7 +22,8 @@ import java.util.List;
public class TaskController { public class TaskController {
@Autowired @Autowired
private ITaskService taskService; private ITaskService taskService;
@Autowired
private IProjectService projectService;
@SneakyThrows @SneakyThrows
@GetMapping("/{fatherId}/subtask") @GetMapping("/{fatherId}/subtask")
public ResponseList<TaskDto> getSubTaskList( public ResponseList<TaskDto> getSubTaskList(
@ -57,6 +60,8 @@ public class TaskController {
@PathVariable("projectId") Integer projectId, @PathVariable("projectId") Integer projectId,
@RequestBody Task task @RequestBody Task task
) { ) {
if(!projectService.checkOpenStatus(projectId))
throw new BadRequestException("项目未开放");
task.setTaskProjectId(projectId); task.setTaskProjectId(projectId);
taskService.insertTask(token, task); taskService.insertTask(token, task);
return ResponseMap.ofSuccess("操作成功"); return ResponseMap.ofSuccess("操作成功");
@ -70,6 +75,8 @@ public class TaskController {
@PathVariable("taskId") Long taskId, @PathVariable("taskId") Long taskId,
@RequestBody Task task @RequestBody Task task
) { ) {
if(!projectService.checkOpenStatus(projectId))
throw new BadRequestException("项目未开放");
task.setTaskProjectId(projectId); task.setTaskProjectId(projectId);
task.setTaskId(taskId); task.setTaskId(taskId);
taskService.modifyTask(token, task); taskService.modifyTask(token, task);
@ -83,6 +90,8 @@ public class TaskController {
@PathVariable("projectId") Integer projectId, @PathVariable("projectId") Integer projectId,
@PathVariable("taskId") Long taskId @PathVariable("taskId") Long taskId
) { ) {
if(!projectService.checkOpenStatus(projectId))
throw new BadRequestException("项目未开放");
taskService.deleteTaskAndSubTask(token, projectId, taskId); taskService.deleteTaskAndSubTask(token, projectId, taskId);
return ResponseMap.ofSuccess("删除成功"); return ResponseMap.ofSuccess("删除成功");
} }

View File

@ -22,4 +22,6 @@ public interface IProjectService extends IService<Project> {
Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException; Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException;
Boolean createProject(String token, Project project) throws BadRequestException; Boolean createProject(String token, Project project) throws BadRequestException;
Boolean checkOpenStatus(Integer projectId);
} }

View File

@ -93,4 +93,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
} }
return false; return false;
} }
public Boolean checkOpenStatus(Integer projectId) {
if (projectId == null || projectId < 1)
return false;
Project project = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, projectId));
return project != null && !project.getCompleted();
}
} }