浏览代码

fix(机构树查询修改): 机构树查询修改

1、机构树查询修改
2、权限中心人员管理列表查询修改
mazq 3 年之前
父节点
当前提交
f514b3dd4f

+ 56 - 8
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/sub/AuthOrgInfoController.java

@@ -18,11 +18,13 @@ import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
 import com.dragonsoft.duceap.base.entity.security.SecurityUser;
 import com.dragonsoft.duceap.base.utils.UserContextUtils;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.collections.ListUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -32,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -225,7 +228,10 @@ public class AuthOrgInfoController {
             String[] orgIdStatus = orgIdStr.split(StrUtil.COLON);
             orgIds.add(orgIdStatus[0]);
         }
-        List<OrgTreeNodeDTO> orgInfosList = authOrgInfoFacade.getOrgTreeNodeByIds(orgIds);
+        List<OrgTreeNodeDTO> orgInfosList = authOrgInfoFacade.getSelfAndChildByIds(orgIds);
+        //组成树结构只返回顶部节点
+        //重新设置权限过滤后的子节点集合和isParent字段
+        orgInfosList = convertFilterTree(orgInfosList, mtAuthIds, true);
         List<OrgTreeNodeVo> collect = orgInfosList.stream().map(e -> {
             e.setChildIds(null);
             OrgTreeNodeVo vo = new OrgTreeNodeVo();
@@ -244,13 +250,8 @@ public class AuthOrgInfoController {
      */
     public List<OrgTreeNodeVo> getChildTreeNode(String id, String mtAuthIds) {
         //子级机构
-        List<OrgTreeNodeDTO> childList = authOrgInfoFacade.getChildById(id);
-        if (StringUtils.isNotEmpty(mtAuthIds)) {
-           childList = childList
-                   .stream()
-                   .filter(e-> OrgInfoUtil.isHaveAuth(e.getId(), e.getPath(), mtAuthIds))
-                   .collect(Collectors.toList());
-        }
+        List<OrgTreeNodeDTO> childList = authOrgInfoFacade.getChildById(id, 2);
+        childList = convertFilterTree(childList, mtAuthIds, true);
         return childList.stream().map(e->{
             OrgTreeNodeVo nodeVo = new OrgTreeNodeVo();
             BeanUtils.copyProperties(e, nodeVo);
@@ -258,4 +259,51 @@ public class AuthOrgInfoController {
         }).collect(Collectors.toList());
     }
 
+    /**
+     * 组成树结构后只返回顶部节点集合
+     * 组成树结构后重新设置权限过滤后的顶节点isParent字段和child字段
+     * @param treeNodeList
+     * @param mtAuthIds
+     * @param needTree 是否需要组装成树结构
+     * @return
+     */
+    private List<OrgTreeNodeDTO> convertFilterTree(List<OrgTreeNodeDTO> treeNodeList, String mtAuthIds, boolean needTree) {
+        List<OrgTreeNodeDTO> collect = new ArrayList<>();
+        if(StringUtils.isEmpty(mtAuthIds)) {
+            return collect;
+        }
+        //筛选有权限的节点
+        collect = treeNodeList
+                .stream()
+                .filter(e -> OrgInfoUtil.isHaveAuth(e.getId(), e.getPath(), mtAuthIds))
+                .collect(Collectors.toList());
+        if(!needTree) {
+            return collect;
+        } else {
+            //重新设置权限过滤后的顶节点isParent字段和child字段
+            //只返回顶部节点集合
+            Map<String, OrgTreeNodeDTO> idMap = collect
+                    .stream()
+                    .collect(Collectors.toMap(OrgTreeNodeDTO::getId, e -> e));
+            Set<String> keySet = idMap.keySet();
+            //筛选父节点
+            List<OrgTreeNodeDTO> allTopNodes = collect.stream().filter(e->{
+                String pid = e.getPid();
+                if(StringUtils.isBlank(pid)) {
+                    return true;
+                }
+                if(!keySet.contains(pid)) {
+                    return true;
+                }
+                return false;
+            }).collect(Collectors.toList());
+            //重新设置父节点isParent字段
+            allTopNodes.forEach(e->{
+                List<String> childIds = e.getChildIds();
+                e.setIsParent(childIds.stream().anyMatch(keySet::contains));
+                e.setChildIds(null);
+            });
+            return allTopNodes;
+        }
+    }
 }

+ 6 - 1
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/sub/AuthUserInfoController.java

@@ -29,11 +29,16 @@ public class AuthUserInfoController {
     @Autowired
     private IAuthUserInfoFacade userInfoFacade;
 
+    /**
+     * 同角色授权-人员视图列表
+     * @param searchable
+     * @return
+     */
     @RequestMapping("/page")
     @ApiImplicitParam(name = "searchable", value = "查询条件")
     @ApiOperation(value = "分页查询用户信息")
     public Page<AuthUserDTO> page(Searchable searchable) {
-        return userInfoFacade.page(searchable.toSearchDTO());
+        return userInfoFacade.roleAuthUserViewPage(searchable.toSearchDTO());
     }
 
     @ApiOperation(value = "用户信息详情")