Browse Source

no message

FengChaoYu 1 tuần trước cách đây
mục cha
commit
311108fc05

+ 31 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java

@@ -662,6 +662,24 @@ public class AdminUserLogic {
                         .filter(adminUserId -> !masterUserIds.contains(adminUserId))
                         .collect(Collectors.toSet());
             }
+
+            // 查询递归查询部门
+            final List<AdminDept> adminDeptList = adminUser.getAdminDept();
+            if (CollectionUtil.isNotEmpty(adminDeptList)) {
+                Set<String> deptIds = new HashSet<>();
+                for (AdminDept dept : adminDeptList) {
+                    deptIds.add(dept.getAdminDeptId());
+                    this.querySubDept(dept, deptIds);
+                }
+                final List<AdminUserDeptRela> deptRelas = adminUserDeptRelaService.lambdaQuery()
+                        .select(AdminUserDeptRela::getAdminUserId)
+                        .eq(AdminUserDeptRela::getAdminDeptId, deptIds)
+                        .list();
+                // 部门相关的adminUserId添加到集合
+                websitUserIds.addAll(deptRelas.stream()
+                        .map(AdminUserDeptRela::getAdminUserId)
+                        .collect(Collectors.toSet()));
+            }
         }
 
         IPage<AdminUser> page = adminUserService.lambdaQuery()
@@ -719,6 +737,19 @@ public class AdminUserLogic {
         return page;
     }
 
+    private void querySubDept(AdminDept dept, Set<String> deptIds) {
+        final List<AdminDept> deptList = adminDeptService.lambdaQuery()
+                .eq(AdminDept::getPId, dept.getAdminDeptId())
+                .list();
+        if (CollectionUtil.isEmpty(deptList)) {
+            return;
+        }
+        for (AdminDept subDept : deptList) {
+            deptIds.add(subDept.getAdminDeptId());
+            this.querySubDept(subDept, deptIds);
+        }
+    }
+
 //    /**
 //     * 根据父角色查询子角色关联的用户id
 //     * @param roleUserIds