feat: 管理员可以抢单,拥有完整权限

- 管理员可以抢单主任务(绕过部门类型、部门负责人限制)
- 管理员可以抢单子任务(绕过所有限制)
- 管理员拥有:发起任务、审核任务、指定任务、抢单、交付等完整权限
This commit is contained in:
Your Name 2026-01-04 08:39:52 +08:00
parent 07ce2e5613
commit d6c81f1fdc
2 changed files with 81 additions and 64 deletions

View File

@ -112,6 +112,11 @@ public class TaskItemService {
throw new BusinessException(ResultCode.NOT_FOUND, "子任务不存在");
}
// 检查是否是管理员(管理员可以抢单,绕过所有限制)
boolean isAdmin = user.getIsAdmin() != null && user.getIsAdmin() == 1;
// 非管理员需要进行权限验证
if (!isAdmin) {
// 验证用户部门权限
if (user.getDeptId() == null) {
throw new BusinessException(ResultCode.FORBIDDEN, "您未分配部门,无法接单");
@ -155,6 +160,9 @@ public class TaskItemService {
}
}
}
} else {
log.info("管理员 {} 抢单子任务 {}", user.getRealName(), itemId);
}
// 验证状态
if (!"pending".equals(item.getStatus())) {

View File

@ -753,7 +753,13 @@ public class TaskService {
throw new BusinessException(ResultCode.FORBIDDEN, "用户不存在");
}
// 检查是否是管理员(管理员可以抢单,绕过所有限制)
boolean isAdmin = isAdminUser(userId);
Long deptId = user.getDeptId();
// 非管理员需要进行权限验证
if (!isAdmin) {
if (deptId == null) {
throw new BusinessException(ResultCode.FORBIDDEN, "您未分配部门,无法接单");
}
@ -783,6 +789,9 @@ public class TaskService {
if (task.getDemandTypeId() != null) {
validateAllowedDemandTypes(department, task.getDemandTypeId());
}
} else {
log.info("管理员 {} 抢单任务 {}", user.getRealName(), taskId);
}
LocalDateTime now = LocalDateTime.now();
// 重新计算deadline:从接单时间开始计算,无论之前是否有deadline