parent
3ff5374347
commit
16f55b05bd
|
@ -1,6 +1,8 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
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.exception.BadRequestException;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
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,6 +22,9 @@ public class TaskController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITaskService taskService;
|
private ITaskService taskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IProjectGroupService projectGroupService;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping("/subtask/{fatherId}")
|
@GetMapping("/subtask/{fatherId}")
|
||||||
public ResponseList<Task> getSubTaskList(
|
public ResponseList<Task> getSubTaskList(
|
||||||
|
@ -39,14 +44,14 @@ public class TaskController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@PostMapping
|
@PostMapping("/subtask/exist")
|
||||||
public ResponseMap createTask(
|
public ResponseMap createTask(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@PathVariable("projectId") Integer projectId,
|
@PathVariable("projectId") Integer projectId,
|
||||||
@RequestBody Task task
|
@RequestParam("taskId") Long taskId
|
||||||
) {
|
) {
|
||||||
task.setTaskProjectId(projectId);
|
return ResponseMap.ofSuccess("返回成功")
|
||||||
task = taskService.insertTask(token, task);
|
.put("existSubTask" ,taskService.existSubTask(token, projectId, taskId));
|
||||||
return ResponseMap.ofSuccess("新建成功", task);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ITaskService extends IService<Task> {
|
public interface ITaskService extends IService<Task> {
|
||||||
List<Task> getTaskList(String token,Integer projectId,Long fatherId) throws BadRequestException;
|
List<Task> getTaskList(String token,Integer projectId,Long fatherId) throws BadRequestException;
|
||||||
List<List<Long>> getTaskAndSubTask(Long taskId);
|
Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||||
Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||||
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||||
Integer checkHolder(Integer staffId,Long taskId);
|
Integer checkHolder(Integer staffId,Long taskId);
|
||||||
|
|
|
@ -38,7 +38,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery().eq(Task::getTaskProjectId, projectId).eq(Task::getTaskFatherId, fatherId));
|
return baseMapper.selectList(Wrappers.<Task>lambdaQuery().eq(Task::getTaskProjectId, projectId).eq(Task::getTaskFatherId, fatherId));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME:
|
@Override
|
||||||
|
public Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
||||||
|
if(projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
||||||
|
throw new BadRequestException("请求参数错误");
|
||||||
|
}
|
||||||
|
return baseMapper.exists(Wrappers.<Task>lambdaQuery().eq(Task::getTaskFatherId, taskId));
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
public Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
||||||
|
@ -67,7 +74,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME:
|
|
||||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
||||||
|
@ -188,7 +194,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
if (!task.checkInsert()) {
|
if (!task.checkInsert()) {
|
||||||
throw new BadRequestException("工作项参数错误");
|
throw new BadRequestException("工作项参数错误");
|
||||||
}
|
}
|
||||||
if (!checkHolder(token, task.getTaskFatherId())) {
|
if (checkHolder(token, task.getTaskFatherId()) == 0) {
|
||||||
throw new BadRequestException("非法的父级参数");
|
throw new BadRequestException("非法的父级参数");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue