{"record":{"id":"32c193b8d0747d45","repo":"paascloud/paascloud-master","slug":"uac10012003","errorCode":"UAC10012003","errorMessage":"系统角色不能删除","messagePattern":"系统角色不能删除","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java","lineNumber":78,"sourceCode":"\t\treturn uacRoleMapper.findByRoleCode(roleCode);\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic List<RoleVo> queryRoleListWithPage(UacRole role) {\n\t\treturn uacRoleMapper.queryRoleListWithPage(role);\n\t}\n\n\t@Override\n\tpublic int deleteRoleById(Long roleId) {\n\t\t//查询该角色下是否有用户绑定, 有的话提醒不能删除\n\t\tif (null == roleId) {\n\t\t\tthrow new IllegalArgumentException(ErrorCodeEnum.UAC10012001.msg());\n\t\t}\n\n\t\t// 超级管理员不能删除\n\t\tif (Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012003);\n\t\t}\n\n\t\tList<UacRoleUser> uruList = uacRoleUserService.listByRoleId(roleId);\n\n\t\tif (!uruList.isEmpty()) {\n\t\t\tuacRoleUserService.deleteByRoleId(roleId);\n\t\t}\n\n\t\tuacRoleActionService.deleteByRoleId(roleId);\n\t\tuacRoleMenuService.deleteByRoleId(roleId);\n\t\treturn uacRoleMapper.deleteByPrimaryKey(roleId);\n\t}\n\n\t@Override\n\tpublic int saveRole(UacRole role, LoginAuthDto loginAuthDto) {\n\t\tint result = 0;\n\t\trole.setUpdateInfo(loginAuthDto);\n\t\tif (role.isNew()) {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java#L60-L96","documentation":"UacBizException UAC10012003 ('系统角色不能删除' / system role cannot be deleted) thrown by UacRoleServiceImpl.deleteRoleById when the target roleId equals GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID. The built-in super-admin role is protected from deletion to keep the system administrable.","triggerScenarios":"Attempting to delete the super-manager role: calling deleteRoleById with the well-known super admin role ID, whether directly via API or through a UI that does not filter it out of the delete list.","commonSituations":"Admin script iterating over all roles and deleting them; UI lacking the super-role guard; data restore/migration re-adding delete requests for the protected role.","solutions":["Exclude the SUPER_MANAGER_ROLE_ID from any bulk delete set before iterating","Filter the super role out of delete-eligible role lists in the UI","Return a clear message to the user that the system role is protected"],"exampleFix":"// before\nroleIds.forEach(id -> uacRoleService.deleteRoleById(id));\n// after\nroleIds.stream()\n    .filter(id -> !Objects.equals(id, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID))\n    .forEach(id -> uacRoleService.deleteRoleById(id));","handlingStrategy":"try-catch","validationCode":"if (Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID)) {\n    return Result.error(\"系统角色不能删除\");\n}","typeGuard":"boolean isSystemRole(Long roleId) { return Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID); }","tryCatchPattern":"try {\n    uacRoleService.deleteRoleById(roleId);\n} catch (UacBizException e) {\n    if (ErrorCodeEnum.UAC10012003.getCode().equals(e.getCode())) {\n        return Result.error(\"系统内置角色不允许删除\");\n    }\n    throw e;\n}","preventionTips":["Filter SUPER_MANAGER_ROLE_ID out of delete-eligible lists","Exclude system roles from bulk-delete iterations","Show the protected flag in role management UIs"],"tags":["java","permission","uac","protected-resource"],"backgroundTag":"permission-denied","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}