jeecgboot/JeecgBoot · error · JeecgBootBizTipException

被拖拽的部门不存在

Error message

被拖拽的部门不存在

What it means

Thrown by SysDepartServiceImpl.updateChangeDepart when baseMapper.getDepartById(dragId) returns null — the dragged department cannot be found. This is a JeecgBootBizTipException that halts the entire department drag-and-drop reordering transaction. It is the first validation step before the target department is even fetched.

Source

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

            }
        }
        return "";
    }

    /**
     * 变更部门位置
     * 
     * @param changeDepartVo
     * @return orgCode 部门id
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void updateChangeDepart(SysChangeDepartVo changeDepartVo) {
        String dragId = changeDepartVo.getDragId();
        // 1. 获取被拖拽的部门
        SysDepart dragDept = baseMapper.getDepartById(dragId);
        if (null == dragDept) {
            throw new JeecgBootBizTipException("被拖拽的部门不存在");
        }
        // 2. 获取目标部门
        String dropId = changeDepartVo.getDropId();
        SysDepart targetDept = baseMapper.getDepartById(dropId);
        if (null == targetDept) {
            throw new JeecgBootBizTipException("目标部门不存在");
        }
        //3. 验证拖拽操作是否合法
        validateDragOperation(dragDept, targetDept, changeDepartVo.getDropPosition());
        //4. 根据dropPosition调整部门顺序
        Integer dropPosition = changeDepartVo.getDropPosition();
        switch (dropPosition) {
            case -1:
                // 拖拽到上方
                moveToAbove(dragDept, targetDept);
                break;
            case 0:
                // 拖拽到内部(作为子部门)

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Refresh the department tree in the frontend before performing drag operations.
  2. Check for concurrent modifications: ensure no other user/session deleted the department between tree load and drag.
  3. If calling programmatically, validate dragId existence before calling updateChangeDepart.
  4. Review getDepartById SQL for tenant filtering that might exclude the department under certain login contexts.

Example fix

// before
SysDepart dragDept = baseMapper.getDepartById(dragId);
if (null == dragDept) {
    throw new JeecgBootBizTipException("被拖拽的部门不存在");
}

// after — frontend validates existence first
// In the drag handler, check that dragId is still in the current tree
// before sending the request. Backend adds a descriptive response:
SysDepart dragDept = baseMapper.getDepartById(dragId);
if (null == dragDept) {
    throw new JeecgBootBizTipException("被拖拽的部门不存在(ID:" + dragId + "),请刷新部门树后重试");
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate dragId exists before calling updateChangeDepart
SysDepart dragDept = baseMapper.getDepartById(dragId);
if (dragDept == null) {
    return Result.error("被拖拽的部门不存在,请刷新部门树后重试");
}
service.updateChangeDepart(changeDepartVo);

Type guard

public boolean isDepartmentExists(String deptId) {
    if (deptId == null || deptId.trim().isEmpty()) return false;
    return baseMapper.getDepartById(deptId) != null;
}

Try / catch

try {
    service.updateChangeDepart(changeDepartVo);
} catch (JeecgBootBizTipException e) {
    if (e.getMessage().contains("被拖拽的部门不存在")) {
        return Result.error("拖拽的部门已被删除,请刷新后重试");
    }
    throw e;
}

Prevention

When it happens

Trigger: A drag-and-drop operation where the dragged department's ID (dragId) references a deleted, non-existent, or cross-tenant department. Common when the frontend tree has stale data from a previous session or another user concurrently deleted the department.

Common situations: Concurrent editing: user A deletes a department while user B has the tree open and drags it; stale client-side state after a page refresh was skipped; race condition between delete and drag operations.

Related errors


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