jeecgboot/JeecgBoot · warning · JeecgBootBizTipException

当前部门类型为【${DepartCategoryEnum.getNameByValue(oldOrgCategory)}

Error message

当前部门类型为【${DepartCategoryEnum.getNameByValue(oldOrgCategory)}】,不允许移动到公司

What it means

Thrown by validateDragOperation when dropPosition != 0 and the target is a company-type department (DEPART_CATEGORY_COMPANY), but the dragged department is not itself a company. This JeecgBootBizTipException enforces the business rule that only companies can be reordered as siblings of other companies. The message dynamically includes the dragged department's category name.

Source

Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java:2069

     * @param dropPosition 拖拽位置
     */
    private void validateDragOperation(SysDepart dragDept, SysDepart targetDept, Integer dropPosition) {
        // 禁止拖拽到自身
        if (dragDept.getId().equals(targetDept.getId())) {
            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) {

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Ensure the dragged department is of company type before dropping it adjacent to another company.
  2. Add a frontend visual restriction: only allow sibling drops on companies if the drag source is also a company.
  3. Review the orgCategory values in the database for both source and target to confirm they are correct.
  4. If the business rule has changed, update the validateDragOperation logic accordingly.

Example fix

// before — backend rejects at validation time
if (!DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(oldOrgCategory)) {
    throw new JeecgBootBizTipException("当前部门类型为【" + DepartCategoryEnum.getNameByValue(oldOrgCategory) + "】,不允许移动到公司");
}

// after — frontend pre-checks category compatibility
function canDropAdjacentToCompany(dragNode, dropNode) {
    if (dropNode.orgCategory !== 'company') return true;
    if (dragNode.orgCategory !== 'company') {
        ElMessage.warning('只有公司类型可以移动到公司旁边');
        return false;
    }
    return true;
}
Defensive patterns

Strategy: validation

Validate before calling

// Frontend: check category compatibility before drop
const isCompany = (node) => node.orgCategory === DepartCategoryEnum.COMPANY;
if (dropPosition !== 0 && isCompany(dropNode) && !isCompany(dragNode)) {
    ElMessage.warning('只有公司类型可以移动到公司旁边');
    return;
}

Type guard

public boolean canMoveAdjacentToCompany(String dragOrgCategory, String targetOrgCategory, int dropPosition) {
    if (dropPosition == 0) return true;
    if (!DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(targetOrgCategory)) return true;
    return DepartCategoryEnum.DEPART_CATEGORY_COMPANY.getValue().equals(dragOrgCategory);
}

Try / catch

try {
    service.updateChangeDepart(changeDepartVo);
} catch (JeecgBootBizTipException e) {
    if (e.getMessage().contains("不允许移动到公司")) {
        return Result.error("部门类型不兼容,只有公司可以移动到公司旁边");
    }
    throw e;
}

Prevention

When it happens

Trigger: Attempting to drag a department or post (not a company) to a position above or below a company node (dropPosition -1 or 1). The DepartCategoryEnum.getNameByValue method resolves the source category for the error message.

Common situations: User misunderstands the organizational hierarchy rules and tries to place a department alongside companies; inconsistent org-category data where a department is miscategorized; frontend doesn't filter drop targets by category compatibility.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/0536656c87fcb198. Report an issue: GitHub.