增加删除的childrenCount
parent
72e23ad0f0
commit
13e9825f75
|
@ -68,10 +68,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
try {
|
||||
List<Long> res = new ArrayList<>();
|
||||
res.add(taskId);
|
||||
Task task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, taskId));
|
||||
Task fatherTask = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskFatherId()));
|
||||
Integer childrenCount = fatherTask.getChildrenCount() - 1;
|
||||
fatherTask.setChildrenCount(childrenCount);
|
||||
if (baseMapper.update(fatherTask, Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, fatherTask.getTaskId())) != 1) {
|
||||
throw new BadRequestException("删除失败");
|
||||
}
|
||||
while (true) {
|
||||
List<Task> list = baseMapper.selectList(
|
||||
Wrappers.<Task>lambdaQuery()
|
||||
.in(Task::getTaskFatherId, res));
|
||||
baseMapper.update(null, Wrappers.<Task>lambdaUpdate().in(Task::getTaskId, res).set(Task::getChildrenCount, 0));
|
||||
baseMapper.delete(Wrappers.<Task>lambdaQuery().in(Task::getTaskId, res));
|
||||
if (list == null || list.isEmpty()) break;
|
||||
res = list.stream().map(Task::getTaskId).collect(Collectors.toList());
|
||||
|
|
Loading…
Reference in New Issue