private List<Long> getJuniorDeptIds(R<List<SysUser>> userList, List<Long> xiajiId) {
List<Long> userIds = new ArrayList<>();
// 创建一个临时列表,用于存储当前层级的下级部门id
List<Long> currentLevelDeptIds = new ArrayList<>(xiajiId);
// 直到没有下级部门为止
while (!currentLevelDeptIds.isEmpty()) {
List<Long> nextLevelDeptIds = new ArrayList<>();
// 遍历当前层级的下级部门id
for (Long deptId : currentLevelDeptIds) {
for (SysUser datum : userList.getData()) {
if (Objects.equals(datum.getDeptId(), deptId)) {
userIds.add(datum.getUserId());
// 将当前部门的所有下级部门id添加到下一层级列表中
nextLevelDeptIds.add(datum.getUserId());
}
}
}
// 更新当前层级的下级部门id为下一层级的部门id
currentLevelDeptIds = nextLevelDeptIds;
}
return userIds;
}
java通过用户id寻找下级
youmdt2023-09-11 10:32
相关推荐
yyy(十一月限定版)几秒前
c++(3)类和对象(中)小杰帅气7 分钟前
进程优先级与切换调度方便面不加香菜8 分钟前
Linux基本指令(1)济61711 分钟前
linux(第十四期)--Uboot移植(1)-- Ubuntu20.04奋斗的阿狸_198612 分钟前
键盘组合键监听与 xterm 唤醒程序IT 行者14 分钟前
Spring Security 7 OAuth2 Token 格式选择浅析小张成长计划..14 分钟前
【linux】2:linux权限的概念马踏岛国赏樱花16 分钟前
Windows与Ubuntu双系统,挂载D/E盘到Ubuntu下时只能读的问题ben9518chen16 分钟前
Linux操作系统基本使用shughui18 分钟前
最新版IntelliJ IDEA下载+安装+汉化(详细图文)