浏览代码

no message

FengChaoYu 3 周之前
父节点
当前提交
7b45adb25b
共有 1 个文件被更改,包括 18 次插入2 次删除
  1. 18 2
      src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java

+ 18 - 2
src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.common;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSON;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
 import com.gree.mall.manager.commonmapper.AdminMapper;
@@ -73,6 +74,8 @@ public class CommonLogic {
 
     private final AdminWebsitService adminWebsitService;
 
+    private final AdminDeptWebsitService adminDeptWebsitService;
+
 
     public AdminUserCom getAdminUser() {
         HttpServletRequest request = ApplicationContextUtils.getHttpServletRequest();
@@ -130,9 +133,8 @@ public class CommonLogic {
                 .map(AdminUserPermissionsRela::getAdminUserPermissionsId)
                 .distinct()
                 .collect(Collectors.toList());
-        adminUserCom.setAdminWebsitIds(websitList);
 
-        // 部门(无任何业务作用)
+        // 部门
         final List<String> deptList = permissionsRelas.stream()
                 .filter(AdminUserPermissionsRela::getIsDept)
                 .map(AdminUserPermissionsRela::getAdminUserPermissionsId)
@@ -140,6 +142,20 @@ public class CommonLogic {
                 .collect(Collectors.toList());
         adminUserCom.setAdminDeptIds(deptList);
 
+        if (CollectionUtil.isNotEmpty(deptList)) {
+            // 找出部门下的商家
+            for (String deptId : deptList) {
+                final List<AdminDeptWebsit> adminDeptWebsits = adminDeptWebsitService.lambdaQuery()
+                        .eq(AdminDeptWebsit::getAdminDeptId, deptId)
+                        .list();
+                final List<String> websitIdList = adminDeptWebsits.stream()
+                        .map(AdminDeptWebsit::getWebsitId)
+                        .collect(Collectors.toList());
+                websitList.addAll(websitIdList);
+            }
+        }
+
+        adminUserCom.setAdminWebsitIds(websitList.stream().distinct().sorted().collect(Collectors.toList()));
 //        adminUserCom.setOnlyRead(companyList.size() > 1);
 
         return adminUserCom;