瀏覽代碼

no message

FengChaoYu 3 周之前
父節點
當前提交
eefd2a244f
共有 1 個文件被更改,包括 24 次插入3 次删除
  1. 24 3
      src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java

+ 24 - 3
src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java

@@ -69,6 +69,8 @@ public class AdminUserLogic {
 
     private final AdminDeptService adminDeptService;
 
+    private final AdminDeptWebsitService adminDeptWebsitService;
+
     @Value("${front.top.url}")
     private String frontTopUrl;
 
@@ -328,7 +330,7 @@ public class AdminUserLogic {
         Set<String> adminUserIdList = new HashSet<>();
         if (!adminUser.getUserName().equals("admin")) {
             // 非admin账号,筛选能看的账号
-//            this.queryCanSeeAdminUser(adminUserIdList, adminUser);
+            this.queryCanSeeAdminUser(adminUserIdList, adminUser);
         }
 
         IPage<AdminUser> page = adminUserService.lambdaQuery()
@@ -343,14 +345,33 @@ public class AdminUserLogic {
     private void queryCanSeeAdminUser(Set<String> adminUserIdList, AdminUserCom adminUser) {
         final List<AdminUserPermissionsRela> permissionsRelaList = adminUserPermissionsRelaService.lambdaQuery()
                 .eq(AdminUserPermissionsRela::getAdminUserId, adminUser.getAdminUserId())
-                .eq(AdminUserPermissionsRela::getIsDept, false)
                 .list();
 
         // 商家id集合
-        final List<String> websitIdList = permissionsRelaList.stream()
+        Set<String> websitIdList = permissionsRelaList.stream()
+                .filter(v -> !v.getIsDept())
+                .map(AdminUserPermissionsRela::getAdminUserPermissionsId)
+                .collect(Collectors.toSet());
+
+        final List<String> deptList = permissionsRelaList.stream()
+                .filter(AdminUserPermissionsRela::getIsDept)
                 .map(AdminUserPermissionsRela::getAdminUserPermissionsId)
+                .distinct()
                 .collect(Collectors.toList());
 
+        if (CollectionUtil.isNotEmpty(deptList)) {
+            // 找出部门下的商家
+            for (String deptId : deptList) {
+                final List<AdminDeptWebsit> adminDeptWebsits = adminDeptWebsitService.lambdaQuery()
+                        .eq(AdminDeptWebsit::getAdminDeptId, deptId)
+                        .list();
+                final List<String> websitIds = adminDeptWebsits.stream()
+                        .map(AdminDeptWebsit::getWebsitId)
+                        .collect(Collectors.toList());
+                websitIdList.addAll(websitIds);
+            }
+        }
+
         // 根据商家id集合查找有关联的账号
         final List<AdminUserPermissionsRela> adminUserPermissionsRelaList = adminUserPermissionsRelaService.lambdaQuery()
                 .select(AdminUserPermissionsRela::getAdminUserId)