添加了已结项项目的工作项变更操作阻止
parent
9690fff08e
commit
cf434fface
|
@ -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.*;
|
||||
|
|
|
@ -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<TaskDto> 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("删除成功");
|
||||
}
|
||||
|
|
|
@ -22,4 +22,6 @@ public interface IProjectService extends IService<Project> {
|
|||
Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException;
|
||||
|
||||
Boolean createProject(String token, Project project) throws BadRequestException;
|
||||
|
||||
Boolean checkOpenStatus(Integer projectId);
|
||||
}
|
||||
|
|
|
@ -93,4 +93,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue