{"record":{"id":"5319de5c0258723f","repo":"jeecgboot/JeecgBoot","slug":"error-5319de","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":1771,"sourceCode":"            //如果不是公司或者子公司的时候，需要递归查询\n            if (oConvertUtils.isNotEmpty(sysDepart.getParentId())) {\n                return getCompanyDepartId(sysDepart.getParentId());\n            } else {\n                return parentDepartId;\n            }\n        } else {\n            return \"\";\n        }\n    }\n\n    @Override\n    public List<SysPositionSelectTreeVo> getRankRelation(String departId) {\n        //记录当前部门 key为部门id,value为部门名称\n        Map<String, String> departNameMap = new HashMap<>(5);\n        //step1 根据id查询部门信息\n        SysDepartPositionVo sysDepartPosition = baseMapper.getDepartPostByDepartId(departId);\n        if (null == sysDepartPosition) {\n            throw new JeecgBootBizTipException(\"当前所选部门数据为空\");\n        }\n        List<SysPositionSelectTreeVo> selectTreeVos = new ArrayList<>();\n        //step2 查看是否有子级部门，存在递归查询职位\n        if (!CommonConstant.IS_LEAF.equals(sysDepartPosition.getIzLeaf())) {\n            //获取子级职位根据部门编码\n            this.getChildrenDepartPositionByOrgCode(selectTreeVos, departNameMap, sysDepartPosition,departId);\n            return buildTree(selectTreeVos);\n        }\n        return new ArrayList<>();\n    }\n\n\t/**\n\t * 获取所有部门职务\n\t * @param departId\n\t * @return\n\t */\n    @Override\n    public List<SysPositionSelectTreeVo> getALLRankRelation(String departId) {","sourceCodeStart":1753,"sourceCodeEnd":1789,"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#L1753-L1789","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the departId is valid and not deleted: query the department list or tree to confirm it still exists for the current tenant.","Ensure the frontend refreshes its department tree after create/delete/drag operations so stale IDs are never passed.","If calling programmatically, validate the ID with baseMapper.selectById(departId) before invoking getRankRelation.","Check getDepartPostByDepartId SQL to confirm the join condition isn't over-filtering (e.g., missing tenant scoping or a bad org_code join)."],"exampleFix":"// before\nSysPositionSelectTreeVo vo = baseMapper.getDepartPostByDepartId(departId);\nif (null == vo) {\n    throw new JeecgBootBizTipException(\"当前所选部门数据为空\");\n}\n\n// after — caller validates before invoking the service\nSysDepart dept = baseMapper.selectById(departId);\nif (dept == null) {\n    return Result.error(\"部门不存在，请刷新后重试\");\n}\nservice.getRankRelation(departId);","handlingStrategy":"validation","validationCode":"// Validate department exists before calling getRankRelation\nSysDepart dept = departMapper.selectById(departId);\nif (dept == null) {\n    return Result.error(\"部门不存在，请刷新部门树\");\n}\nList<SysPositionSelectTreeVo> tree = service.getRankRelation(departId);","typeGuard":"public boolean isDepartValid(String departId) {\n    if (departId == null || departId.trim().isEmpty()) return false;\n    return baseMapper.selectById(departId) != null;\n}","tryCatchPattern":"try {\n    List<SysPositionSelectTreeVo> tree = service.getRankRelation(departId);\n} catch (JeecgBootBizTipException e) {\n    if (\"当前所选部门数据为空\".equals(e.getMessage())) {\n        return Result.error(\"部门数据不存在，请刷新后重试\");\n    }\n    throw e;\n}","preventionTips":["Refresh the department tree after any create/delete/drag operation.","Validate department IDs on the frontend before making service calls.","Handle stale-ID scenarios gracefully with user-friendly messages."],"tags":["jeecg-boot","department","null-check","business-exception"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}