修复部门成员数统计和子部门查询逻辑

This commit is contained in:
Your Name 2026-01-20 14:28:55 +08:00
parent 3e74be7087
commit a6812d1d34
2 changed files with 10 additions and 2 deletions

View File

@ -499,7 +499,12 @@ public class DepartmentService {
}
private Map<Long, Long> loadMemberCountMap() {
return userMapper.selectList(null).stream()
// 只统计启用且未删除的用户
return userMapper.selectList(
new LambdaQueryWrapper<User>()
.eq(User::getStatus, 1)
.eq(User::getDeleted, 0)
).stream()
.filter(user -> user.getDeptId() != null)
.collect(Collectors.groupingBy(
User::getDeptId,
@ -601,10 +606,12 @@ public class DepartmentService {
return result;
}
// 查找直接子部门
// 查找直接子部门(只查询未删除且启用的部门)
List<Department> children = departmentMapper.selectList(
new LambdaQueryWrapper<Department>()
.eq(Department::getParentId, deptId)
.eq(Department::getDeleted, 0)
.eq(Department::getStatus, 1)
);
// 递归获取所有子部门
@ -613,6 +620,7 @@ public class DepartmentService {
result.addAll(getAllChildDeptIds(child.getId()));
}
log.info("获取部门{}的所有子部门ID: {}", deptId, result);
return result;
}

Binary file not shown.