{"record":{"id":"b9ad99afb5fcdc80","repo":"jeecgboot/JeecgBoot","slug":"error-b9ad99","errorCode":null,"errorMessage":"岗位不允许存在子级","messagePattern":"岗位不允许存在子级","errorType":"exception","errorClass":"JeecgBootBizTipException","httpStatus":null,"severity":"warning","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java","lineNumber":2074,"sourceCode":"            throw new RuntimeException(\"不能拖拽到自身\");\n        }\n        // 禁止拖拽到自身子部门\n        if (isDescendant(dragDept, targetDept.getId())) {\n            throw new RuntimeException(\"不能拖拽到自身子部门\");\n        }\n        //公司岗位判断\n        String orgCategory = targetDept.getOrgCategory();\n        String oldOrgCategory = dragDept.getOrgCategory();\n        //部门为公司\n        if(0 != dropPosition && DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(orgCategory)){\n            //当前部门不能为子公司、部门和岗位\n            if(!DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(oldOrgCategory)){\n                throw new JeecgBootBizTipException(\"当前部门类型为【\"+DepartCategoryEnum.getNameByValue(oldOrgCategory)+\"】,不允许移动到公司\");\n            }\n        }\n        //部门为岗位不允许移入\n        if(0 == dropPosition && DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(orgCategory)) {\n            throw new JeecgBootBizTipException(\"岗位不允许存在子级\");\n        }\n        //公司不能做为子级\n        if(oConvertUtils.isNotEmpty(targetDept.getParentId()) && DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(oldOrgCategory)){\n            throw new JeecgBootBizTipException(\"公司不允许作为子级\");\n        }\n    }\n\n    /**\n     * 判断目标部门是否是被拖拽部门的子部门\n     */\n    private boolean isDescendant(SysDepart dragDept, String targetId) {\n        List<SysDepart> children = departMapper.getDepartByParentId(dragDept.getId());\n        for (SysDepart child : children) {\n            if (child.getId().equals(targetId)) {\n                return true;\n            }\n            if (isDescendant(child, targetId)) {\n                return true;","sourceCodeStart":2056,"sourceCodeEnd":2092,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java#L2056-L2092","documentation":"Thrown by validateDragOperation when dropPosition == 0 (drop inside as child) and the target department is of post/position type (DEPART_CATEGORY_POST). This JeecgBootBizTipException enforces the rule that a position node is always a leaf — it cannot have children. Posts represent individual job positions, not organizational containers.","triggerScenarios":"Dropping a department or node inside a post-type department (dropPosition=0), attempting to make it a child of a position. The switch condition catches (0 == dropPosition && POST type).","commonSituations":"User tries to nest departments under a position node; tree UI allows drop-inside on all nodes regardless of type; org structure was set up with positions where departments were intended.","solutions":["Add a frontend guard: disable 'drop inside' (position 0) for any node whose orgCategory is 'post'.","Verify the target department's orgCategory is correct — if it should be a department not a post, fix the data.","Display clear tooltips in the UI explaining that positions cannot contain children."],"exampleFix":"// before\nif (0 == dropPosition && DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(orgCategory)) {\n    throw new JeecgBootBizTipException(\"岗位不允许存在子级\");\n}\n\n// after — frontend prevents drop-inside on post nodes\nfunction allowDropInside(dragNode, dropNode) {\n    if (dropNode.orgCategory === 'post') {\n        return false; // post nodes are always leaf\n    }\n    return true;\n}","handlingStrategy":"validation","validationCode":"// Frontend: prevent drop-inside on post-type nodes\nconst isPost = (node) => node.orgCategory === DepartCategoryEnum.POST;\nif (dropPosition === 0 && isPost(dropNode)) {\n    ElMessage.warning('岗位不允许存在子级');\n    return;\n}","typeGuard":"public boolean canDropInside(String targetOrgCategory) {\n    return !DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(targetOrgCategory);\n}","tryCatchPattern":"try {\n    service.updateChangeDepart(changeDepartVo);\n} catch (JeecgBootBizTipException e) {\n    if (e.getMessage().contains(\"岗位不允许存在子级\")) {\n        return Result.error(\"岗位节点不能包含子部门\");\n    }\n    throw e;\n}","preventionTips":["Disable 'drop inside' for post-type nodes in the tree UI.","Verify orgCategory data is correct in the database.","Show leaf-node indicators for post-type departments."],"tags":["jeecg-boot","department","drag-drop","business-rule","leaf-node"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}