{"record":{"id":"1a95219562d81c4e","repo":"paascloud/paascloud-master","slug":"uac10015007","errorCode":"UAC10015007","errorMessage":"该组织下还存在子节点，不能将其删除, Pid=%s","messagePattern":"该组织下还存在子节点，不能将其删除, Pid=(.+?)","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java","lineNumber":161,"sourceCode":"\t}\n\n\t@Override\n\tpublic int deleteUacGroupById(Long id) {\n\n\t\tPreconditions.checkArgument(id != null, \"组织id为空\");\n\t\tPreconditions.checkArgument(!Objects.equals(id, GlobalConstant.Sys.SUPER_MANAGER_GROUP_ID), \"该组织不能删除\");\n\n\t\t// 根据前台传入的组织参数校验该组织是否存在\n\t\tUacGroup uacGroup = uacGroupMapper.selectByPrimaryKey(id);\n\t\tif (PublicUtil.isEmpty(uacGroup)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10015004, id);\n\t\t}\n\t\t//判断该组织下是否存在子节点\n\t\tUacGroup childGroup = new UacGroup();\n\t\tchildGroup.setPid(id);\n\t\tList<UacGroup> childGroupList = uacGroupMapper.select(childGroup);\n\t\tif (PublicUtil.isNotEmpty(childGroupList)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10015007, id);\n\t\t}\n\t\t//判断该组织下是否存在用户\n\t\tUacGroupUser uacGroupUser = new UacGroupUser();\n\t\tuacGroupUser.setGroupId(id);\n\t\tList<UacGroupUser> uacGroupUserList = uacGroupUserMapper.select(uacGroupUser);\n\t\tif (PublicUtil.isNotEmpty(uacGroupUserList)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10015008, id);\n\t\t}\n\n\t\treturn mapper.deleteByPrimaryKey(id);\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic UacGroup queryById(Long groupId) {\n\t\tPreconditions.checkArgument(PublicUtil.isNotEmpty(groupId), \"组织Id不能为空\");\n\t\tUacGroup query = new UacGroup();\n\t\tquery.setId(groupId);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java#L143-L179","documentation":"UAC10015007 (\"该组织下还存在子节点，不能将其删除, Pid=%s\") is thrown by deleteUacGroupById when the target group still has child organizations (uac_group rows with pid = id). Deleting would orphan the subtree, so it is refused.","triggerScenarios":"Calling deleteUacGroupById(id) where uacGroupMapper.select(childGroup with pid=id) returns a non-empty child list.","commonSituations":"Deleting a parent department instead of the intended leaf; UI tree not expanding children so hidden sub-organizations exist; data imported with hierarchy the user is unaware of.","solutions":["Delete or move all child organizations first, then delete the parent","Catch UacBizException UAC10015007 and show the child count / prompt to handle children first","Use a cascade-delete API (if provided) that removes the subtree in order when that is the intent"],"exampleFix":"// before\nuacGroupService.deleteUacGroupById(parentId);\n// after\nList<UacGroup> children = uacGroupService.getChildGroups(parentId); // or query pid = parentId\nfor (UacGroup child : children) {\n    uacGroupService.deleteUacGroupById(child.getId()); // delete leaves first\n}\nuacGroupService.deleteUacGroupById(parentId);","handlingStrategy":"validation","validationCode":"List<UacGroup> children = uacGroupMapper.select(new UacGroup().setPid(groupId));\nif (!children.isEmpty()) { throw new IllegalStateException(\"Group has \" + children.size() + \" children; delete them first\"); }","typeGuard":null,"tryCatchPattern":"try {\n    uacGroupService.deleteUacGroupById(groupId);\n} catch (UacBizException e) {\n    if (ErrorCodeEnum.UAC10015007.getCode().equals(e.getCode())) { /* show child groups, offer cascade or move */ }\n    else throw e;\n}","preventionTips":["Expand/load full subtrees in the UI before allowing delete","Offer a 'delete subtree' flow that removes leaves first","Audit imported data for unexpected hierarchy depth"],"tags":["hierarchy","organization","delete","referential-integrity"],"backgroundTag":"invalid-state-transition","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"}