Commit a51d2a0cfe9bd4c01e519dc963753aa86b1f99fd

Authored by 王彪总
1 parent fca77767

fix(user): 修复部门层级查找逻辑

- 当找不到parentId=100的部门时,返回当前部门id作为默认值
- 修改顶级部门查找逻辑,返回顶级部门ID而不是null
- 避免因返回null导致的空指针异常问题
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/service/user/AdminUserServiceImpl.java
@@ -688,7 +688,9 @@ public class AdminUserServiceImpl implements AdminUserService { @@ -688,7 +688,9 @@ public class AdminUserServiceImpl implements AdminUserService {
688 } 688 }
689 689
690 // 递归查找父部门链中parentId=100的部门 690 // 递归查找父部门链中parentId=100的部门
691 - return findParentDeptWithParentId(dept.getParentId(), 100L); 691 + Long result = findParentDeptWithParentId(dept.getParentId(), 100L);
  692 + // 如果找不到parentId=100的部门,返回当前部门的id作为默认值
  693 + return result != null ? result : dept.getId();
692 } 694 }
693 695
694 /** 696 /**
@@ -714,7 +716,7 @@ public class AdminUserServiceImpl implements AdminUserService { @@ -714,7 +716,7 @@ public class AdminUserServiceImpl implements AdminUserService {
714 716
715 // 达到顶级部门,停止递归 717 // 达到顶级部门,停止递归
716 if (dept.getParentId().equals(0L)) { 718 if (dept.getParentId().equals(0L)) {
717 - return null; 719 + return dept.getId(); // 改为返回顶级部门ID,而不是null
718 } 720 }
719 721
720 // 继续向上查找 722 // 继续向上查找