修复了upperBound的边界问题,添加了异常签名

master
白封羽 2022-07-12 16:30:37 +08:00
parent 76966938a1
commit 6a37f2387e
2 changed files with 7 additions and 2 deletions

View File

@ -38,7 +38,7 @@ public interface ITaskService extends IService<Task> {
*/ */
Integer getHolderLevel(String token, Long taskId); Integer getHolderLevel(String token, Long taskId);
List<TaskDTO> listMyTasks(String token, Integer projectId) throws BadRequestException; List<TaskDTO> listMyTasks(String token, Integer projectId) throws BadRequestException, ForbiddenException;
Boolean canBeDone(Long taskId); Boolean canBeDone(Long taskId);

View File

@ -210,6 +210,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
private int upperBound(List<Task> data, long x) { private int upperBound(List<Task> data, long x) {
int l = 0, r = data.size() - 1; int l = 0, r = data.size() - 1;
if(data.get(r).getTaskFatherId().equals(x))
return r;
while (l < r) { while (l < r) {
int mid = (l + r) / 2; int mid = (l + r) / 2;
if (data.get(mid).getTaskFatherId() <= x) l = mid + 1; if (data.get(mid).getTaskFatherId() <= x) l = mid + 1;
@ -220,8 +222,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
@Override @Override
public List<TaskDTO> listMyTasks(String token, Integer projectId) { public List<TaskDTO> listMyTasks(String token, Integer projectId) throws ForbiddenException {
Integer staffId = TokenUtils.getStaffId(token); Integer staffId = TokenUtils.getStaffId(token);
if(projectGroupService.getProjectAccessLevel(token,projectId)==0){
throw new ForbiddenException("不可操作的项目");
}
List<Task> resList = baseMapper.selectList(Wrappers.<Task>lambdaQuery() List<Task> resList = baseMapper.selectList(Wrappers.<Task>lambdaQuery()
.select(Task::getTaskId, Task::getTaskFatherId, Task::getTaskHolderId) .select(Task::getTaskId, Task::getTaskFatherId, Task::getTaskHolderId)
.eq(Task::getTaskProjectId, projectId) .eq(Task::getTaskProjectId, projectId)