jeecgboot/JeecgBoot · warning · JeecgBootBizTipException
岗位不允许存在子级
Error message
岗位不允许存在子级
What it means
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.
Source
Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java:2074
throw new RuntimeException("不能拖拽到自身");
}
// 禁止拖拽到自身子部门
if (isDescendant(dragDept, targetDept.getId())) {
throw new RuntimeException("不能拖拽到自身子部门");
}
//公司岗位判断
String orgCategory = targetDept.getOrgCategory();
String oldOrgCategory = dragDept.getOrgCategory();
//部门为公司
if(0 != dropPosition && DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(orgCategory)){
//当前部门不能为子公司、部门和岗位
if(!DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(oldOrgCategory)){
throw new JeecgBootBizTipException("当前部门类型为【"+DepartCategoryEnum.getNameByValue(oldOrgCategory)+"】,不允许移动到公司");
}
}
//部门为岗位不允许移入
if(0 == dropPosition && DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(orgCategory)) {
throw new JeecgBootBizTipException("岗位不允许存在子级");
}
//公司不能做为子级
if(oConvertUtils.isNotEmpty(targetDept.getParentId()) && DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(oldOrgCategory)){
throw new JeecgBootBizTipException("公司不允许作为子级");
}
}
/**
* 判断目标部门是否是被拖拽部门的子部门
*/
private boolean isDescendant(SysDepart dragDept, String targetId) {
List<SysDepart> children = departMapper.getDepartByParentId(dragDept.getId());
for (SysDepart child : children) {
if (child.getId().equals(targetId)) {
return true;
}
if (isDescendant(child, targetId)) {
return true;View on GitHub (pinned to 96fb33f5ec)
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.
Example fix
// before
if (0 == dropPosition && DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(orgCategory)) {
throw new JeecgBootBizTipException("岗位不允许存在子级");
}
// after — frontend prevents drop-inside on post nodes
function allowDropInside(dragNode, dropNode) {
if (dropNode.orgCategory === 'post') {
return false; // post nodes are always leaf
}
return true;
} Defensive patterns
Strategy: validation
Validate before calling
// Frontend: prevent drop-inside on post-type nodes
const isPost = (node) => node.orgCategory === DepartCategoryEnum.POST;
if (dropPosition === 0 && isPost(dropNode)) {
ElMessage.warning('岗位不允许存在子级');
return;
} Type guard
public boolean canDropInside(String targetOrgCategory) {
return !DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(targetOrgCategory);
} Try / catch
try {
service.updateChangeDepart(changeDepartVo);
} catch (JeecgBootBizTipException e) {
if (e.getMessage().contains("岗位不允许存在子级")) {
return Result.error("岗位节点不能包含子部门");
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/b9ad99afb5fcdc80.
Report an issue: GitHub.