Commit 8c0a19613ec26d25258df09e52545ee4d7d090cd
1 parent
8e43004c
fix(crm):数据权限切面对无登录用户的系统调用放行,修公海自动掉落 Null key(A34)
公海自动掉落定时任务(crmCustomerAutoPutPoolJob,ForkJoinPool 线程无登录 用户)→ putCustomerPool → contactService.updateOwnerUserIdByCustomerId (@CrmPermission)→ CrmPermissionAspect.validatePermission → isCrmAdmin() → hasAnyRoles(null) → @Cacheable(user_role_ids, key=#userId) 取值为 null,Spring 6 抛 IllegalArgumentException: Null key,事务回滚, 客户永远掉不进公海(job 日志恒"掉入公海客户 0 个",2026-09-21 23:50:36 实抓全链路堆栈:CrmCustomerServiceImpl:459/476 → CrmPermissionAspect:70 → CrmPermissionUtils:36 → PermissionServiceImpl:261)。 数据权限是按登录用户的访问控制:/admin-api 外部请求必有登录用户, 登录用户为 null 只可能是系统内部可信调用,切面入口直接放行; 用户发起路径行为不变。
Showing
1 changed file
with
7 additions
and
0 deletions
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java
| ... | ... | @@ -45,6 +45,13 @@ public class CrmPermissionAspect { |
| 45 | 45 | |
| 46 | 46 | @Before("@annotation(crmPermission)") |
| 47 | 47 | public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { |
| 48 | + // 0. 系统调用(定时任务/异步线程等,无登录用户)不走数据权限校验,直接放行。 | |
| 49 | + // 数据权限是“按登录用户”的访问控制;/admin-api 外部请求必然有登录用户, | |
| 50 | + // 故登录用户为 null 只可能是系统内部调用(如公海自动掉落定时任务),属可信进程。 | |
| 51 | + // 若在此校验,isCrmAdmin() 会以 null 用户查缓存,抛 Null key 异常导致业务失败。 | |
| 52 | + if (getUserId() == null) { | |
| 53 | + return; | |
| 54 | + } | |
| 48 | 55 | // 1.1 获取相关属性值 |
| 49 | 56 | Map<String, Object> expressionValues = parseExpressions(joinPoint, crmPermission); |
| 50 | 57 | Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? | ... | ... |