fix: 修复接单部门负责人驳回任务时,任务未指定接单部门的权限验证问题
This commit is contained in:
parent
f18b3da725
commit
a88d077dda
@ -999,11 +999,32 @@ public class TaskItemService {
|
||||
boolean isAdmin = rejector != null && Integer.valueOf(1).equals(rejector.getIsAdmin());
|
||||
|
||||
if (!isAdmin) {
|
||||
if (mainTask.getReceiverDeptId() == null) {
|
||||
throw new BusinessException(ResultCode.FORBIDDEN, "任务未指定接单部门");
|
||||
boolean hasPermission = false;
|
||||
|
||||
if (mainTask.getReceiverDeptId() != null) {
|
||||
// 如果任务已指定接单部门,检查用户是否是该部门的负责人
|
||||
com.designhub.entity.Department receiverDept = departmentMapper.selectById(mainTask.getReceiverDeptId());
|
||||
if (receiverDept != null && rejectorId.equals(receiverDept.getLeaderId())) {
|
||||
hasPermission = true;
|
||||
log.info("用户 {} 是任务接单部门 {} 的负责人", rejectorId, mainTask.getReceiverDeptId());
|
||||
}
|
||||
} else {
|
||||
// 如果任务未指定接单部门,检查用户是否是任何接单部门的负责人
|
||||
List<com.designhub.entity.Department> receivingDepts = departmentMapper.selectList(
|
||||
new LambdaQueryWrapper<com.designhub.entity.Department>()
|
||||
.eq(com.designhub.entity.Department::getLeaderId, rejectorId)
|
||||
.eq(com.designhub.entity.Department::getDeptType, "receiving")
|
||||
.eq(com.designhub.entity.Department::getStatus, 1)
|
||||
.eq(com.designhub.entity.Department::getDeleted, 0)
|
||||
);
|
||||
if (!receivingDepts.isEmpty()) {
|
||||
hasPermission = true;
|
||||
log.info("用户 {} 是接单部门负责人(管理的接单部门:{}),允许驳回未指定接单部门的任务",
|
||||
rejectorId, receivingDepts.stream().map(com.designhub.entity.Department::getDeptName).collect(java.util.stream.Collectors.toList()));
|
||||
}
|
||||
}
|
||||
com.designhub.entity.Department receiverDept = departmentMapper.selectById(mainTask.getReceiverDeptId());
|
||||
if (receiverDept == null || !rejectorId.equals(receiverDept.getLeaderId())) {
|
||||
|
||||
if (!hasPermission) {
|
||||
throw new BusinessException(ResultCode.FORBIDDEN, "只有接单部门负责人可以驳回子任务组");
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user