{"record":{"id":"0d02cd76eac0d8e0","repo":"jeecgboot/JeecgBoot","slug":"error-0d02cd","errorCode":null,"errorMessage":"目标部门不存在","messagePattern":"目标部门不存在","errorType":"exception","errorClass":"JeecgBootBizTipException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java","lineNumber":2020,"sourceCode":"     * 变更部门位置\n     * \n     * @param changeDepartVo\n     * @return orgCode 部门id\n     */\n    @Transactional(rollbackFor = Exception.class)\n    @Override\n    public void updateChangeDepart(SysChangeDepartVo changeDepartVo) {\n        String dragId = changeDepartVo.getDragId();\n        // 1. 获取被拖拽的部门\n        SysDepart dragDept = baseMapper.getDepartById(dragId);\n        if (null == dragDept) {\n            throw new JeecgBootBizTipException(\"被拖拽的部门不存在\");\n        }\n        // 2. 获取目标部门\n        String dropId = changeDepartVo.getDropId();\n        SysDepart targetDept = baseMapper.getDepartById(dropId);\n        if (null == targetDept) {\n            throw new JeecgBootBizTipException(\"目标部门不存在\");\n        }\n        //3. 验证拖拽操作是否合法\n        validateDragOperation(dragDept, targetDept, changeDepartVo.getDropPosition());\n        //4. 根据dropPosition调整部门顺序\n        Integer dropPosition = changeDepartVo.getDropPosition();\n        switch (dropPosition) {\n            case -1:\n                // 拖拽到上方\n                moveToAbove(dragDept, targetDept);\n                break;\n            case 0:\n                // 拖拽到内部（作为子部门）\n                moveAsChild(dragDept, targetDept);\n                break;\n            case 1:\n                //拖拽到下方\n                moveToBelow(dragDept, targetDept, changeDepartVo.getSort());\n                break;","sourceCodeStart":2002,"sourceCodeEnd":2038,"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#L2002-L2038","documentation":"Thrown by SysDepartServiceImpl.updateChangeDepart when baseMapper.getDepartById(dropId) returns null — the target (drop) department cannot be found. This JeecgBootBizTipException fires after the dragged department is confirmed to exist, halting the transaction before drag validation logic runs.","triggerScenarios":"A drag-and-drop where the target department ID (dropId) references a deleted or non-existent department. Happens when the target was removed by another user, or the frontend passes a virtual/internal node ID that has no backing database record.","commonSituations":"Concurrent deletion of the target department; frontend tree component passes an internal tree-node ID that doesn't correspond to a real SYS_DEPART row; tenant context mismatch during the drop request.","solutions":["Refresh the department tree to ensure the target node still exists.","Verify the frontend passes the actual department ID (not a tree-component-internal ID) as dropId.","Check for concurrent modifications by other users or sessions.","Confirm the dropId is within the same tenant scope as the logged-in user."],"exampleFix":"// before\nSysDepart targetDept = baseMapper.getDepartById(dropId);\nif (null == targetDept) {\n    throw new JeecgBootBizTipException(\"目标部门不存在\");\n}\n\n// after — frontend ensures dropId is valid before API call\n// Only allow drop on nodes confirmed to be real departments:\nif (!treeNode.isRealDepartment()) {\n    ElMessage.warning('目标节点无效，请刷新后重试');\n    return;\n}\nawait api.updateChangeDepart({ dragId, dropId: treeNode.id, dropPosition });","handlingStrategy":"validation","validationCode":"// Validate dropId exists before calling updateChangeDepart\nSysDepart targetDept = baseMapper.getDepartById(dropId);\nif (targetDept == null) {\n    return Result.error(\"目标部门不存在，请刷新部门树后重试\");\n}\nservice.updateChangeDepart(changeDepartVo);","typeGuard":"public boolean isDropTargetValid(String dropId) {\n    if (dropId == null || dropId.trim().isEmpty()) return false;\n    return baseMapper.getDepartById(dropId) != null;\n}","tryCatchPattern":"try {\n    service.updateChangeDepart(changeDepartVo);\n} catch (JeecgBootBizTipException e) {\n    if (e.getMessage().contains(\"目标部门不存在\")) {\n        return Result.error(\"目标部门已被删除，请刷新后重试\");\n    }\n    throw e;\n}","preventionTips":["Refresh the department tree before performing drop operations.","Ensure the frontend passes real department IDs, not tree-component internal IDs.","Validate both drag and drop IDs before sending the request."],"tags":["jeecg-boot","department","drag-drop","null-check","business-exception"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}