Browse Source

代理商管理处理二级问题

mingfu 1 month ago
parent
commit
0b48a172ed

+ 10 - 4
ie-admin/src/main/java/com/ruoyi/web/controller/dz/DzAgentController.java

@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.google.common.collect.Lists;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -55,14 +56,16 @@ public class DzAgentController extends BaseController
     public AjaxResult list(DzAgent dzAgent)
     {
         SysUser sysUser = SecurityUtils.getLoginUser().getUser();
+        List<DzAgent> allList = Lists.newArrayList();
         if(UserTypeEnum.isAgent(sysUser.getUserType())) {
             dzAgent.setParentId(sysUser.getUserTypeId());
+            allList.add(dzAgentService.selectDzAgentByAgentId(sysUser.getUserTypeId()));
         } else if(!UserTypeEnum.isSys(sysUser.getUserType())) {
             dzAgent.setDeptId(sysUser.getDeptId());
         }
-        List<DzAgent> list = dzAgentService.selectDzAgentList(dzAgent);
+        allList.addAll(dzAgentService.selectDzAgentList(dzAgent));
         //处理关联学校的显示
-        List<Long> distinctSchoolIds = list.stream()
+        List<Long> distinctSchoolIds = allList.stream()
                 .map(DzAgent::getSchoolIds)
                 .filter(Objects::nonNull)        // 过滤null数组
                 .filter(array -> array.length > 0) // 过滤空数组
@@ -72,7 +75,7 @@ public class DzAgentController extends BaseController
         //查询学校名称
         if (CollectionUtil.isNotEmpty(distinctSchoolIds)){
             Map<Long, DzSchool> schoolMap = schoolService.selectDzSchoolListByIds(distinctSchoolIds).stream().collect(Collectors.toMap(DzSchool::getId, school -> school));
-            for (DzAgent agent : list) {
+            for (DzAgent agent : allList) {
                 if (agent.getSchoolIds() != null&&agent.getSchoolIds().length>0) {
                     String schoolName = Arrays.stream(agent.getSchoolIds())
                             .filter(Objects::nonNull)  // 过滤null值
@@ -87,7 +90,7 @@ public class DzAgentController extends BaseController
             }
         }
 
-        return success(list);
+        return success(allList);
     }
 
     /**
@@ -121,6 +124,9 @@ public class DzAgentController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody DzAgent dzAgent)
     {
+        if(UserTypeEnum.isAgent(SecurityUtils.getLoginUser().getUser().getUserType())) {
+            dzAgent.setParentId(SecurityUtils.getLoginUser().getUser().getUserTypeId());
+        }
         setSchools(dzAgent);
         return toAjax(dzAgentService.insertDzAgent(dzAgent));
     }

+ 1 - 1
ie-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -48,7 +48,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 机构信息集合
      */
     @Override
-    @DataScope(deptAlias = "d")
+    @DataScope(deptAlias = "d", permission = "system:dept:query")
     public List<SysDept> selectDeptList(SysDept dept)
     {
         return deptMapper.selectDeptList(dept);