{"record":{"id":"f7946aeaa18751d3","repo":"paascloud/paascloud-master","slug":"uac10012007","errorCode":"UAC10012007","errorMessage":"ErrorCodeEnum.UAC10012007","messagePattern":"ErrorCodeEnum\\.UAC10012007","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleUserServiceImpl.java","lineNumber":136,"sourceCode":"\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic List<UacRoleUser> listByUserId(Long userId) {\n\t\tif (userId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011001);\n\t\t}\n\t\treturn uacRoleUserMapper.listByUserId(userId);\n\t}\n\n\t@Override\n\tpublic void deleteByRoleIdList(List<Long> roleIdList) {\n\t\tPreconditions.checkArgument(PublicUtil.isNotEmpty(roleIdList), ErrorCodeEnum.UAC10012001.msg());\n\t\tPreconditions.checkArgument(!roleIdList.contains(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID), \"超级管理员角色不能删除\");\n\t\tint result = uacRoleUserMapper.deleteByRoleIdList(roleIdList);\n\t\tif (result < roleIdList.size()) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012007, Joiner.on(GlobalConstant.Symbol.COMMA).join(roleIdList));\n\t\t}\n\t}\n\n\t@Override\n\tpublic void deleteByRoleId(Long roleId) {\n\t\tPreconditions.checkArgument(roleId != null, ErrorCodeEnum.UAC10012001.msg());\n\t\tPreconditions.checkArgument(!Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID), \"超级管理员角色不能删除\");\n\n\t\tint result = uacRoleUserMapper.deleteByRoleId(roleId);\n\t\tif (result < 1) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012006, roleId);\n\t\t}\n\t}\n}\n","sourceCodeStart":118,"sourceCodeEnd":151,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleUserServiceImpl.java#L118-L151","documentation":"UacBizException with code UAC10012007 (role-user binding batch delete failed) thrown by deleteByRoleIdList when the number of deleted rows is less than the size of the given roleIdList. The service treats a partial delete as a failure and reports the affected role ids in the message.","triggerScenarios":"deleteByRoleIdList(roleIdList) where one or more role ids in the list have no role-user rows (rows already deleted, or ids referencing non-existent roles), so uacRoleUserMapper.deleteByRoleIdList returns fewer rows than roleIdList.size().","commonSituations":"Re-running a delete after a partially completed previous attempt; list contains role ids that never had users assigned; concurrent transactions removed some bindings first.","solutions":["Verify each roleId in the list has at least one role-user binding before batch deletion, or only delete ids known to have bindings.","Make deletion idempotent in the caller: treat 'already deleted' as success and retry without the missing ids.","Catch UacBizException, parse the reported role ids, and remove only those still present."],"exampleFix":"// before\nuacRoleUserService.deleteByRoleIdList(roleIdList);\n// after\nList<Long> existing = filterRolesWithBindings(roleIdList);\nif (PublicUtil.isNotEmpty(existing)) {\n    uacRoleUserService.deleteByRoleIdList(existing);\n}","handlingStrategy":"try-catch","validationCode":"List<Long> existing = roleIdList.stream()\n    .filter(id -> PublicUtil.isNotEmpty(uacRoleUserService.listByRoleId(id)))\n    .collect(Collectors.toList());\nif (PublicUtil.isNotEmpty(existing)) { uacRoleUserService.deleteByRoleIdList(existing); }","typeGuard":"boolean deletable = roleIdList != null && !roleIdList.isEmpty() && !roleIdList.contains(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);","tryCatchPattern":"try {\n    uacRoleUserService.deleteByRoleIdList(roleIdList);\n} catch (UacBizException e) {\n    if (\"UAC10012007\".equals(e.getCode())) { log.warn(\"partial delete: {}\", e.getMessage()); return; }\n    throw e;\n}","preventionTips":["Design delete flows to be idempotent","Check bindings exist before batch deletes","Exclude role ids without bindings from the batch"],"tags":["database","role-management","partial-delete"],"backgroundTag":"database-write-failed","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"}