更新了checkHolder

master
白封羽 2022-07-05 20:06:21 +08:00
parent 4ca6b5a164
commit 9e579148e7
3 changed files with 24 additions and 11 deletions

View File

@ -33,7 +33,8 @@ public class Task {
private Boolean deleted; private Boolean deleted;
public Boolean checkInsert() { public Boolean checkInsert() {
if (this.getTaskName() == null || this.getTaskName().length() <= 0 || this.getTaskName().length() >= 100) if (this.getTaskName() == null || this.getTaskName().length() <= 0 || this.getTaskName().length() >= 100||
(this.getAttachedInfo()!=null&&this.getAttachedInfo().length() > 250))
return false; return false;
return !this.getTaskEndTime().isBefore(this.getTaskStartTime()); return !this.getTaskEndTime().isBefore(this.getTaskStartTime());
} }

View File

@ -16,8 +16,8 @@ public interface ITaskService extends IService<Task> {
List<List<Long>> getTaskAndSubTask(Long taskId); 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;
Boolean checkHolder(Integer staffId,Long taskId); Integer checkHolder(Integer staffId,Long taskId);
Boolean checkHolder(String token,Long taskId); Integer checkHolder(String token,Long taskId);
List<Task> getMyTaskList(String token,Integer projectId) throws BadRequestException; List<Task> getMyTaskList(String token,Integer projectId) throws BadRequestException;
Boolean canBeDone(Long taskId); Boolean canBeDone(Long taskId);
Task insertTask(String token,Task task) throws BadRequestException; Task insertTask(String token,Task task) throws BadRequestException;

View File

@ -95,30 +95,42 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
} }
} }
/**
*
* @return 1:all rights 2:father holder 3:current holder 0:no right
*/
@Override @Override
public Boolean checkHolder(Integer staffId, Long taskId) { public Integer checkHolder(Integer staffId, Long taskId) {
try { try {
Task task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, taskId)); Task task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, taskId));
if (task == null || staffId <= 0) if (task == null || staffId <= 0)
return false; return 0;
while (task.getTaskFatherId() != 0) { int count=0;
if(task.getTaskHolderId().equals(staffId))
count++;
task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskFatherId()));
while (task.getTaskId() != 0) {
if (Objects.equals(task.getTaskHolderId(), staffId)) if (Objects.equals(task.getTaskHolderId(), staffId))
return true; return 2;
task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskFatherId())); task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskFatherId()));
} }
return false; return count;
} catch (Exception e) { } catch (Exception e) {
return false; return 0;
} }
} }
/**
*
* @return 1:all rights 2:father holder 3:current holder 0:no right
*/
@Override @Override
public Boolean checkHolder(String token, Long taskId) { public Integer checkHolder(String token, Long taskId) {
try { try {
Integer staffId = TokenUtils.getStaffId(token); Integer staffId = TokenUtils.getStaffId(token);
return checkHolder(staffId, taskId); return checkHolder(staffId, taskId);
} catch (Exception e) { } catch (Exception e) {
return false; return 0;
} }
} }