Просмотр исходного кода

feature(机构树节点查询修改): 机构树节点查询修改

机构树节点查询修改
mazq 3 лет назад
Родитель
Сommit
b9b1d7af88

+ 3 - 3
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/sub/business/impl/AuthOrgBusinessImpl.java

@@ -142,7 +142,7 @@ public class AuthOrgBusinessImpl implements IAuthOrgBusiness {
 
     @Override
     public ResponseDTO<List<AuthOrgDTO>> orgMatch(String name, String mts, Integer pageNum, Integer pageSize) {
-        return authOrgInfoService.orgMatch(name, pageNum, pageSize);
+        return authOrgInfoService.orgMatch(name, mts, pageNum, pageSize);
     }
 
     @Override
@@ -174,12 +174,12 @@ public class AuthOrgBusinessImpl implements IAuthOrgBusiness {
 
     @Override
     public OrgTreeNodeDTO getOrgTreeNode(String id) {
-        return null;
+        return authOrgTreeService.getOrgTreeNode(id);
     }
 
     @Override
     public List<OrgTreeNodeDTO> getOrgTreeNodeByIds(List<String> ids) {
-        return null;
+        return authOrgTreeService.getOrgTreeNodeByIds(ids);
     }
 
 

+ 0 - 2
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/sub/facade/AuthOrgInfoFacade.java

@@ -3,12 +3,10 @@ package com.dragoninfo.dcuc.auth.sub.facade;
 import com.dragoninfo.dcuc.auth.sub.business.IAuthOrgBusiness;
 import com.dragoninfo.dcuc.auth.sub.dto.AuthOrgDTO;
 import com.dragoninfo.dcuc.auth.sub.dto.OrgTreeNodeDTO;
-import com.dragoninfo.dcuc.auth.sub.entity.AuthOrgInfo;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
 import com.dragonsoft.duceap.core.search.Searchable;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.RequestMapping;

+ 3 - 16
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/sub/repo/AuthOrgInfoRepository.java

@@ -44,24 +44,11 @@ public interface AuthOrgInfoRepository extends BaseRepository<AuthOrgInfo, Strin
     /**
      * 机构树搜索
      * @param name
-     * @param limitSize
-     * @param pageSize
      * @return
      */
-    @Query(value = "select t.id as id,t.full_name,t.code" +
+    @Query(value = "select t.id, t.full_name, t.code, t.path" +
             " from t_auth_org_info t" +
             " where t.deleted = '0' and (t.full_name like CONCAT('%',:name,'%') or t.code like CONCAT('%',:name,'%'))" +
-            " order by t.org_level asc limit :limitSize, :pageSize", nativeQuery = true)
-    List<AuthOrgInfo> orgMatch(@Param("name") String name,@Param("limitSize") Integer limitSize,@Param("pageSize") Integer pageSize);
-
-
-    /**
-     * 机构搜索数量
-     * @param name
-     * @return
-     */
-    @Query(value = "select count(id)" +
-            " from t_auth_org_info t" +
-            " where t.deleted = '0' and t.full_name like CONCAT('%',:name,'%') or t.code like CONCAT('%',:name,'%')", nativeQuery = true)
-    Integer orgMatchCount(@Param("name") String name);
+            " order by t.org_level asc", nativeQuery = true)
+    List<AuthOrgInfo> orgMatch(@Param("name") String name);
 }

+ 2 - 3
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/sub/service/IAuthOrgInfoService.java

@@ -1,14 +1,12 @@
 package com.dragoninfo.dcuc.auth.sub.service;
 
 import com.dragoninfo.dcuc.auth.sub.dto.AuthOrgDTO;
-import com.dragoninfo.dcuc.auth.sub.dto.OrgTreeNodeDTO;
 import com.dragoninfo.dcuc.auth.sub.entity.AuthOrgInfo;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.core.search.Searchable;
 import org.springframework.data.domain.Page;
 
 import java.util.List;
-import java.util.Set;
 
 /**
  * @author wangrs
@@ -101,11 +99,12 @@ public interface IAuthOrgInfoService{
     /**
      * 名称或是code查询机构
      * @param name
+     * @param mts
      * @param pageNum
      * @param pageSize
      * @return
      */
-    ResponseDTO<List<AuthOrgDTO>> orgMatch(String name, Integer pageNum, Integer pageSize);
+    ResponseDTO<List<AuthOrgDTO>> orgMatch(String name, String mts, Integer pageNum, Integer pageSize);
 
     String getRootOrgId();
 }

+ 8 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/sub/service/IAuthOrgTreeService.java

@@ -26,6 +26,13 @@ public interface IAuthOrgTreeService {
      */
     OrgTreeNodeDTO getOrgTreeNode(String id);
 
+    /**
+     * 批量获取机构树节点
+     * @param ids
+     * @return
+     */
+    List<OrgTreeNodeDTO> getOrgTreeNodeByIds(List<String> ids);
+
     /**
      * 把管理范围转换成所以的机构集合
      * @param mtIds 管理范围
@@ -36,5 +43,6 @@ public interface IAuthOrgTreeService {
     /**
      * 重新构建机构树
      */
+
     void reInitTrees();
 }

+ 16 - 12
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/sub/service/impl/AuthOrgInfoService.java

@@ -1,11 +1,10 @@
 package com.dragoninfo.dcuc.auth.sub.service.impl;
 
 import com.dragoninfo.dcuc.auth.sub.dto.AuthOrgDTO;
-import com.dragoninfo.dcuc.auth.sub.dto.OrgTreeNodeDTO;
 import com.dragoninfo.dcuc.auth.sub.entity.AuthOrgInfo;
 import com.dragoninfo.dcuc.auth.sub.repo.AuthOrgInfoRepository;
-import com.dragoninfo.dcuc.auth.sub.repo.ChildCountDO;
 import com.dragoninfo.dcuc.auth.sub.service.IAuthOrgInfoService;
+import com.dragoninfo.duceap.commons.util.server.OrgInfoUtil;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
@@ -150,16 +149,21 @@ public class AuthOrgInfoService implements IAuthOrgInfoService {
     }
 
     @Override
-    public ResponseDTO<List<AuthOrgDTO>> orgMatch(String name, Integer pageNum, Integer pageSize) {
-        Integer limit = (pageNum-1) * pageSize;
-        List<AuthOrgInfo> list = orgInfoRepository.orgMatch(name, limit, pageSize);
-        List<AuthOrgDTO> collect = list.stream().map(item -> {
-            AuthOrgDTO orgDTO = new AuthOrgDTO();
-            BeanUtils.copyProperties(item, orgDTO);
-            return orgDTO;
-        }).collect(Collectors.toList());
-        Integer count = orgInfoRepository.orgMatchCount(name);
-        return ResponseDTO.success("" + count, collect);
+    public ResponseDTO<List<AuthOrgDTO>> orgMatch(String name, String mts, Integer pageNum, Integer pageSize) {
+        List<AuthOrgInfo> list = orgInfoRepository.orgMatch(name);
+        if(StringUtils.isNotBlank(mts)) {
+            list = list.stream()
+                    .filter(e-> OrgInfoUtil.isHaveAuth(e.getId(), e.getPath(), mts))
+                    .collect(Collectors.toList());
+        }
+        List<AuthOrgDTO> collect = list
+                .stream().skip(pageNum * pageSize).limit(pageSize)
+                .map(item -> {
+                    AuthOrgDTO orgDTO = new AuthOrgDTO();
+                    BeanUtils.copyProperties(item, orgDTO);
+                    return orgDTO;
+                }).collect(Collectors.toList());
+        return ResponseDTO.success("" + list.size(), collect);
     }
 
 }

+ 13 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/sub/service/impl/AuthOrgTreeServiceImpl.java

@@ -80,6 +80,19 @@ public class AuthOrgTreeServiceImpl implements IAuthOrgTreeService {
         return deepCopy(orgTreeNodeDTO);
     }
 
+    @Override
+    public List<OrgTreeNodeDTO> getOrgTreeNodeByIds(List<String> ids) {
+        if(CollectionUtils.isEmpty(ids)) {
+            return new ArrayList<>();
+        }
+        Map<String, OrgTreeNodeDTO> treeNodeMap = holder.getTreeNodeMap();
+        List<OrgTreeNodeDTO> collect = ids
+                .stream()
+                .map(treeNodeMap::get)
+                .collect(Collectors.toList());
+        return deepCopy(collect);
+    }
+
     @Override
     public Set<String> getAllMtOrgIds(String mtIds) {
         Set<String> resultSet = new HashSet<>();