浏览代码

1.资产列表查询权限修改

GouGengquan 4 月之前
父节点
当前提交
c34ff23a18
共有 1 个文件被更改,包括 14 次插入2 次删除
  1. 14 2
      service/src/main/java/com/dayou/service/impl/AssetsServiceImpl.java

+ 14 - 2
service/src/main/java/com/dayou/service/impl/AssetsServiceImpl.java

@@ -103,11 +103,23 @@ public class AssetsServiceImpl extends ServiceImpl<AssetsMapper, Assets> impleme
     public Page<AssetsVO> selectPage(Page page, AssetsSelectDTO assetsSelectDTO) {
         // 判断是否要根据部门id集合查询(部门待办查询)
         if (ObjectUtil.isNotNull(assetsSelectDTO.getSelectByDepartment()) && assetsSelectDTO.getSelectByDepartment()){
-            assetsSelectDTO.setDepartmentIdList(departmentMapper.getDepIdList(LoginContext.getLoginCacheUserBO().getDepartmentList().get(0).getId()));
+            List<Long> depIds = new ArrayList<>();
+            for (SimpleParentModel postModel : LoginContext.getLoginCacheUserBO().getDepartmentList()) {
+                // 根据部门id获取部门及其下属部门的id
+                depIds.addAll(departmentMapper.getDepIdList(postModel.getId()));
+            }
+            // 去重并赋值
+            assetsSelectDTO.setDepartmentIdList(depIds.stream().distinct().collect(Collectors.toList()));
         }
         // 判断是否要查询资产列表,资产列表只能查询包含本人及其所在部门的人员为项目负责人或项目经理的流程(资产列表查询)
         if (ObjectUtil.isNotNull(assetsSelectDTO.getSelectByAll()) && assetsSelectDTO.getSelectByAll()){
-            assetsSelectDTO.setDepartmentIdList(departmentMapper.getDepIdList(LoginContext.getLoginCacheUserBO().getDepartmentList().get(0).getId()));
+            List<Long> depIds = new ArrayList<>();
+            for (SimpleParentModel postModel : LoginContext.getLoginCacheUserBO().getDepartmentList()) {
+                // 根据部门id获取部门及其下属部门的id
+                depIds.addAll(departmentMapper.getDepIdList(postModel.getId()));
+            }
+            // 去重并赋值
+            assetsSelectDTO.setDepartmentIdList(depIds.stream().distinct().collect(Collectors.toList()));
         }
         // 此处判断handlerId是否为空只是为了确保前端查询条件有handlerId,并不直接信任
         if (ObjectUtil.isNotNull(assetsSelectDTO) && ObjectUtil.isNotNull(assetsSelectDTO.getHandlerId())){