Compare commits
2 Commits
152131c4d7
...
12467b6778
Author | SHA1 | Date |
---|---|---|
yang.yongquan | 12467b6778 | |
yang.yongquan | d41a0eb83a |
|
@ -13,6 +13,9 @@ import java.util.List;
|
|||
*/
|
||||
public interface ITaskService extends IService<Task> {
|
||||
List<Task> getTaskList(String token,Integer projectId,Long fatherId) throws BadRequestException;
|
||||
List<List<Long>> getTaskAndSubTask(Long taskId);
|
||||
Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||
Boolean checkHolder(Integer staffId,Long taskId);
|
||||
Boolean checkHolder(String token,Long taskId);
|
||||
List<Task> getMyTaskList(String token,Integer projectId) throws BadRequestException;
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 张韬
|
||||
|
@ -36,6 +37,59 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery().eq(Task::getTaskProjectId,projectId).eq(Task::getTaskFatherId,fatherId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<Long>> getTaskAndSubTask(Long taskId) {
|
||||
List<List<Long>> resList = new ArrayList<>();
|
||||
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 resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException{
|
||||
if(projectGroupService.getUserLevelInGroup(token,projectId)==0) {
|
||||
throw new BadRequestException("错误参数");
|
||||
}
|
||||
if(!checkHolder(token, taskId)) {
|
||||
throw new BadRequestException("错误父级参数");
|
||||
}
|
||||
List<List<Long>> resList = getTaskAndSubTask(taskId);
|
||||
try {
|
||||
for (List<Long> list: resList) {
|
||||
baseMapper.delete(Wrappers.<Task>lambdaQuery().in(Task::getTaskId, list));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException{
|
||||
if(projectGroupService.getUserLevelInGroup(token,projectId)==0) {
|
||||
throw new BadRequestException("错误参数");
|
||||
}
|
||||
if(!checkHolder(token, taskId)) {
|
||||
throw new BadRequestException("错误父级参数");
|
||||
}
|
||||
List<List<Long>> resList = getTaskAndSubTask(taskId);
|
||||
try {
|
||||
for (List<Long> list: resList) {
|
||||
baseMapper.update(null, Wrappers.<Task>lambdaUpdate().in(Task::getTaskId, list).set(Task::getTaskType, "关闭"));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkHolder(Integer staffId,Long taskId){
|
||||
try{
|
||||
|
|
Loading…
Reference in New Issue