jeecgboot/JeecgBoot · warning · JeecgBootBizTipException

当前所选部门数据为空

Error message

当前所选部门数据为空

What it means

Thrown by SysDepartServiceImpl.getRankRelation when baseMapper.getDepartPostByDepartId(departId) returns null, meaning no department record (with position/post data) exists for the supplied departId. This is a JeecgBootBizTipException, the framework's standard 'business tip' exception that surfaces as a user-facing error response. It guards the start of the rank-relation tree-building flow before any child-position recursion.

Source

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

            //如果不是公司或者子公司的时候,需要递归查询
            if (oConvertUtils.isNotEmpty(sysDepart.getParentId())) {
                return getCompanyDepartId(sysDepart.getParentId());
            } else {
                return parentDepartId;
            }
        } else {
            return "";
        }
    }

    @Override
    public List<SysPositionSelectTreeVo> getRankRelation(String departId) {
        //记录当前部门 key为部门id,value为部门名称
        Map<String, String> departNameMap = new HashMap<>(5);
        //step1 根据id查询部门信息
        SysDepartPositionVo sysDepartPosition = baseMapper.getDepartPostByDepartId(departId);
        if (null == sysDepartPosition) {
            throw new JeecgBootBizTipException("当前所选部门数据为空");
        }
        List<SysPositionSelectTreeVo> selectTreeVos = new ArrayList<>();
        //step2 查看是否有子级部门,存在递归查询职位
        if (!CommonConstant.IS_LEAF.equals(sysDepartPosition.getIzLeaf())) {
            //获取子级职位根据部门编码
            this.getChildrenDepartPositionByOrgCode(selectTreeVos, departNameMap, sysDepartPosition,departId);
            return buildTree(selectTreeVos);
        }
        return new ArrayList<>();
    }

	/**
	 * 获取所有部门职务
	 * @param departId
	 * @return
	 */
    @Override
    public List<SysPositionSelectTreeVo> getALLRankRelation(String departId) {

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Verify the departId is valid and not deleted: query the department list or tree to confirm it still exists for the current tenant.
  2. Ensure the frontend refreshes its department tree after create/delete/drag operations so stale IDs are never passed.
  3. If calling programmatically, validate the ID with baseMapper.selectById(departId) before invoking getRankRelation.
  4. Check getDepartPostByDepartId SQL to confirm the join condition isn't over-filtering (e.g., missing tenant scoping or a bad org_code join).

Example fix

// before
SysPositionSelectTreeVo vo = baseMapper.getDepartPostByDepartId(departId);
if (null == vo) {
    throw new JeecgBootBizTipException("当前所选部门数据为空");
}

// after — caller validates before invoking the service
SysDepart dept = baseMapper.selectById(departId);
if (dept == null) {
    return Result.error("部门不存在,请刷新后重试");
}
service.getRankRelation(departId);
Defensive patterns

Strategy: validation

Validate before calling

// Validate department exists before calling getRankRelation
SysDepart dept = departMapper.selectById(departId);
if (dept == null) {
    return Result.error("部门不存在,请刷新部门树");
}
List<SysPositionSelectTreeVo> tree = service.getRankRelation(departId);

Type guard

public boolean isDepartValid(String departId) {
    if (departId == null || departId.trim().isEmpty()) return false;
    return baseMapper.selectById(departId) != null;
}

Try / catch

try {
    List<SysPositionSelectTreeVo> tree = service.getRankRelation(departId);
} catch (JeecgBootBizTipException e) {
    if ("当前所选部门数据为空".equals(e.getMessage())) {
        return Result.error("部门数据不存在,请刷新后重试");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling getRankRelation(departId) with a departId that has been deleted, is from a different tenant, has a stale cached ID, or whose underlying SYS_DEPART row returns no join result from getDepartPostByDepartId (e.g., the department exists but has no matching position mapping row).

Common situations: Stale department ID passed from the frontend tree component after a department was reorganized or deleted; cross-tenant access where the mapper filters by tenant and returns nothing; soft-deleted department still referenced in a cached client-side tree.

Related errors


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