完成了Task的间接拥有权限检测

master
白封羽 2022-07-04 19:06:27 +08:00
parent 1df322ecbe
commit f7a420ca73
2 changed files with 20 additions and 1 deletions

View File

@ -13,4 +13,5 @@ import java.util.List;
*/ */
public interface ITaskService extends IService<Task> { public interface ITaskService extends IService<Task> {
List<Task> getTaskList(String token,Integer projectId,Integer fatherId) throws BadRequestException; List<Task> getTaskList(String token,Integer projectId,Integer fatherId) throws BadRequestException;
Boolean checkHolder(Integer staffId,Integer taskId);
} }

View File

@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author * @author
@ -29,6 +30,23 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
if(projectGroupServiceImpl.getUserLevelInGroup(token,projectId)==0||fatherId==null){ if(projectGroupServiceImpl.getUserLevelInGroup(token,projectId)==0||fatherId==null){
throw new BadRequestException("错误的访问参数"); throw new BadRequestException("错误的访问参数");
} }
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).eq(Task::getDeleted,false));
}
@Override
public Boolean checkHolder(Integer staffId,Integer taskId){
try{
Task task=baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId,taskId));
if(task==null||staffId<=0)
return false;
while(task.getTaskFatherId()!=0){
if(Objects.equals(task.getTaskHolderId(), staffId))
return true;
task=baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId,task.getTaskFatherId()));
}
return false;
}catch(Exception e){
return false;
}
} }
} }