Commit ac6645d0b3c0da0f02613cae9a64737eeecc2e76
Merge branch 'master-jdk17' of https://github.com/YunaiV/ruoyi-vue-pro into master-jdk17
Showing
3 changed files
with
12 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,6 +45,13 @@ public class CrmPermissionAspect { | ||
| 45 | 45 | ||
| 46 | @Before("@annotation(crmPermission)") | 46 | @Before("@annotation(crmPermission)") |
| 47 | public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { | 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 | // 1.1 获取相关属性值 | 55 | // 1.1 获取相关属性值 |
| 49 | Map<String, Object> expressionValues = parseExpressions(joinPoint, crmPermission); | 56 | Map<String, Object> expressionValues = parseExpressions(joinPoint, crmPermission); |
| 50 | Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? | 57 | Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? |
yudao-module-mall/yudao-module-product/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java
| @@ -16,6 +16,7 @@ public interface ErrorCodeConstants { | @@ -16,6 +16,7 @@ public interface ErrorCodeConstants { | ||
| 16 | ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_008_001_003, "存在子分类,无法删除"); | 16 | ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_008_001_003, "存在子分类,无法删除"); |
| 17 | ErrorCode CATEGORY_DISABLED = new ErrorCode(1_008_001_004, "商品分类({})已禁用,无法使用"); | 17 | ErrorCode CATEGORY_DISABLED = new ErrorCode(1_008_001_004, "商品分类({})已禁用,无法使用"); |
| 18 | ErrorCode CATEGORY_HAVE_BIND_SPU = new ErrorCode(1_008_001_005, "类别下存在商品,无法删除"); | 18 | ErrorCode CATEGORY_HAVE_BIND_SPU = new ErrorCode(1_008_001_005, "类别下存在商品,无法删除"); |
| 19 | + ErrorCode CATEGORY_PARENT_IS_SELF = new ErrorCode(1_008_001_006, "父分类不能设置为分类自身"); | ||
| 19 | 20 | ||
| 20 | // ========== 商品品牌相关编号 1-008-002-000 ========== | 21 | // ========== 商品品牌相关编号 1-008-002-000 ========== |
| 21 | ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1_008_002_000, "品牌不存在"); | 22 | ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1_008_002_000, "品牌不存在"); |
yudao-module-mall/yudao-module-product/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java
| @@ -55,6 +55,10 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { | @@ -55,6 +55,10 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { | ||
| 55 | public void updateCategory(ProductCategorySaveReqVO updateReqVO) { | 55 | public void updateCategory(ProductCategorySaveReqVO updateReqVO) { |
| 56 | // 校验分类是否存在 | 56 | // 校验分类是否存在 |
| 57 | validateProductCategoryExists(updateReqVO.getId()); | 57 | validateProductCategoryExists(updateReqVO.getId()); |
| 58 | + // 校验父分类不能是分类自身(环检测:父级设成自己会形成循环层级,后续按父链遍历将死循环/脏数据) | ||
| 59 | + if (Objects.equals(updateReqVO.getParentId(), updateReqVO.getId())) { | ||
| 60 | + throw exception(CATEGORY_PARENT_IS_SELF); | ||
| 61 | + } | ||
| 58 | // 校验父分类存在 | 62 | // 校验父分类存在 |
| 59 | validateParentProductCategory(updateReqVO.getParentId()); | 63 | validateParentProductCategory(updateReqVO.getParentId()); |
| 60 | 64 |