Compare commits
No commits in common. "16f55b05bd98dff50033991e0b71011578fce892" and "9e579148e739941b8944655323800ec2771b20b7" have entirely different histories.
16f55b05bd
...
9e579148e7
|
@ -1,8 +1,6 @@
|
||||||
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;
|
||||||
|
@ -22,9 +20,6 @@ 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(
|
||||||
|
@ -44,14 +39,14 @@ public class TaskController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@PostMapping("/subtask/exist")
|
@PostMapping
|
||||||
public ResponseMap createTask(
|
public ResponseMap createTask(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@PathVariable("projectId") Integer projectId,
|
@PathVariable("projectId") Integer projectId,
|
||||||
@RequestParam("taskId") Long taskId
|
@RequestBody Task task
|
||||||
) {
|
) {
|
||||||
return ResponseMap.ofSuccess("返回成功")
|
task.setTaskProjectId(projectId);
|
||||||
.put("existSubTask" ,taskService.existSubTask(token, projectId, taskId));
|
task = taskService.insertTask(token, task);
|
||||||
|
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;
|
||||||
Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
List<List<Long>> getTaskAndSubTask(Long taskId);
|
||||||
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,35 +38,36 @@ 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
|
@Override
|
||||||
public Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
public List<List<Long>> getTaskAndSubTask(Long taskId) {
|
||||||
if(projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
List<List<Long>> resList = new ArrayList<>();
|
||||||
throw new BadRequestException("请求参数错误");
|
List<Long> res = new ArrayList<>();
|
||||||
|
res.add(taskId);
|
||||||
|
resList.add(res);
|
||||||
|
while (true) {
|
||||||
|
List<Task> list = baseMapper.selectList(Wrappers.<Task>lambdaQuery().in(Task::getTaskFatherId, res));
|
||||||
|
if (list == null || list.isEmpty()) break;
|
||||||
|
res = list.stream().map(Task::getTaskId).collect(Collectors.toList());
|
||||||
|
resList.add(res);
|
||||||
}
|
}
|
||||||
return baseMapper.exists(Wrappers.<Task>lambdaQuery().eq(Task::getTaskFatherId, taskId));
|
return resList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME:
|
||||||
@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 {
|
||||||
Integer level = checkHolder(token, taskId);
|
|
||||||
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
||||||
throw new BadRequestException("错误参数");
|
throw new BadRequestException("错误参数");
|
||||||
}
|
}
|
||||||
if (level == 0 || level == 3) {
|
if (!checkHolder(token, taskId)) {
|
||||||
throw new BadRequestException("错误父级参数");
|
throw new BadRequestException("错误父级参数");
|
||||||
}
|
}
|
||||||
|
List<List<Long>> resList = getTaskAndSubTask(taskId);
|
||||||
try {
|
try {
|
||||||
List<Long> res = new ArrayList<>();
|
for (List<Long> list : resList) {
|
||||||
res.add(taskId);
|
baseMapper.delete(Wrappers.<Task>lambdaQuery().in(Task::getTaskId, list));
|
||||||
while (true) {
|
|
||||||
List<Task> list = baseMapper.selectList(
|
|
||||||
Wrappers.<Task>lambdaQuery()
|
|
||||||
.in(Task::getTaskFatherId, res)
|
|
||||||
.ne(Task::getTaskStatus, "已完成"));
|
|
||||||
baseMapper.delete(Wrappers.<Task>lambdaQuery().in(Task::getTaskId, res));
|
|
||||||
if (list == null || list.isEmpty()) break;
|
|
||||||
res = list.stream().map(Task::getTaskId).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -74,33 +75,19 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
//FIXME:
|
||||||
@Override
|
@Override
|
||||||
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
||||||
Integer level = checkHolder(token, taskId);
|
|
||||||
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
||||||
throw new BadRequestException("错误参数");
|
throw new BadRequestException("错误参数");
|
||||||
}
|
}
|
||||||
if (level == 0) {
|
if (!checkHolder(token, taskId)) {
|
||||||
throw new BadRequestException("错误父级参数");
|
throw new BadRequestException("错误父级参数");
|
||||||
}
|
}
|
||||||
|
List<List<Long>> resList = getTaskAndSubTask(taskId);
|
||||||
try {
|
try {
|
||||||
List<Long> res = new ArrayList<>();
|
for (List<Long> list : resList) {
|
||||||
res.add(taskId);
|
baseMapper.update(null, Wrappers.<Task>lambdaUpdate().in(Task::getTaskId, list).set(Task::getTaskStatus, "关闭"));
|
||||||
while (true) {
|
|
||||||
List<Task> list = baseMapper.selectList(
|
|
||||||
Wrappers.<Task>lambdaQuery()
|
|
||||||
.in(Task::getTaskFatherId, res)
|
|
||||||
.ne(Task::getTaskStatus, "已完成")
|
|
||||||
);
|
|
||||||
baseMapper.update(
|
|
||||||
null,
|
|
||||||
Wrappers.<Task>lambdaUpdate()
|
|
||||||
.in(Task::getTaskId, res)
|
|
||||||
.set(Task::getTaskStatus, "关闭")
|
|
||||||
);
|
|
||||||
if (list == null || list.isEmpty()) break;
|
|
||||||
res = list.stream().map(Task::getTaskId).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -194,7 +181,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()) == 0) {
|
if (!checkHolder(token, task.getTaskFatherId())) {
|
||||||
throw new BadRequestException("非法的父级参数");
|
throw new BadRequestException("非法的父级参数");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue