From 45102fc13900aad6d117b00a4feeeafe9c3f5fee Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 27 五月 2025 21:04:09 +0800
Subject: [PATCH] 优化查询业主成员

---
 service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnerMembersCmd.java |   64 ++++++++++++++-----------------
 1 files changed, 29 insertions(+), 35 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnerMembersCmd.java b/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnerMembersCmd.java
index b5f71ae..34807cb 100644
--- a/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnerMembersCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnerMembersCmd.java
@@ -11,10 +11,14 @@
 import com.java110.intf.common.IFileRelInnerServiceSMO;
 import com.java110.intf.community.IMenuInnerServiceSMO;
 import com.java110.intf.user.IOwnerInnerServiceSMO;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.ListUtil;
 import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
 import com.java110.vo.api.ApiOwnerDataVo;
 import com.java110.vo.api.ApiOwnerVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,31 +45,29 @@
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         Assert.jsonObjectHaveKey(reqJson, "communityId", "璇锋眰涓湭鍖呭惈communityId淇℃伅");
         // Assert.jsonObjectHaveKey(reqJson, "ownerTypeCd", "璇锋眰涓湭鍖呭惈ownerTypeCd淇℃伅");
-
-        if(!reqJson.containsKey("page")){
-            reqJson.put("page",1);
+        if (!reqJson.containsKey("page")) {
+            reqJson.put("page", 1);
         }
-        if(!reqJson.containsKey("row")){
-            reqJson.put("row",10);
+        if (!reqJson.containsKey("row")) {
+            reqJson.put("row", 10);
         }
-
     }
 
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         String userId = context.getReqHeaders().get("user-id");
         OwnerDto ownerDto = BeanConvertUtil.covertBean(reqJson, OwnerDto.class);
-        ownerDto.setOwnerTypeCds(new String[]{"1002", "1003", "1004", "1005"});
+        ownerDto.setOwnerTypeCd(OwnerDto.OWNER_TYPE_CD_MEMBER);
 
         int row = reqJson.getInteger("row");
         //鏌ヨ鎬昏褰曟暟
         int total = ownerInnerServiceSMOImpl.queryOwnersMemberCount(ownerDto);
 
-        List<OwnerDto> ownerDtoList = null;
+        List<OwnerDto> ownerDtos = null;
         if (total > 0) {
-            ownerDtoList = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
-        }else {
-            ownerDtoList = new ArrayList<>();
+            ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
+        } else {
+            ownerDtos = new ArrayList<>();
         }
         //鏌ヨ鏄惁鏈夎劚鏁忔潈闄�
         List<Map> privileges = null;
@@ -73,34 +75,26 @@
         basePrivilegeDto.setResource("/roomCreateFee");
         basePrivilegeDto.setUserId(userId);
         privileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto);
-        if (privileges == null || privileges.size() == 0) {
-            for (OwnerDto owner : ownerDtoList) {
-                String idCard = owner.getIdCard();
-                if (!StringUtil.isEmpty(idCard)) {
-                    idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16);
-                    owner.setIdCard(idCard);
-                }
-                String link = owner.getLink();
-                if (!StringUtil.isEmpty(link)) {
-                    link = link.substring(0, 3) + "****" + link.substring(7);
-                    owner.setLink(link);
+        if (ListUtil.isNull(privileges)) {
+            for (OwnerDto owner : ownerDtos) {
+                try {
+                    String idCard = owner.getIdCard();
+                    if (!StringUtil.isEmpty(idCard)) {
+                        idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16);
+                        owner.setIdCard(idCard);
+                    }
+                    String link = owner.getLink();
+                    if (!StringUtil.isEmpty(link)) {
+                        link = link.substring(0, 3) + "****" + link.substring(7);
+                        owner.setLink(link);
+                    }
+                }catch (Exception e){
+                    e.printStackTrace();
                 }
             }
         }
-        for (OwnerDto ownerdto : ownerDtoList) {
-            FileRelDto fileRelDto = new FileRelDto();
-            fileRelDto.setObjId(ownerdto.getMemberId());
-            List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto);
-            if(fileRelDtos != null && fileRelDtos.size() > 0){
-                ownerdto.setUrl(fileRelDtos.get(0).getFileSaveName());
-            }
-        }
-        ApiOwnerVo apiOwnerVo = new ApiOwnerVo();
-        apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtoList, ApiOwnerDataVo.class));
-        apiOwnerVo.setTotal(total);
-        apiOwnerVo.setRecords((int) Math.ceil((double) total / (double) row));
 
-        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiOwnerVo), HttpStatus.OK);
+        ResponseEntity<String> responseEntity = ResultVo.createResponseEntity((int) Math.ceil((double) total / (double) row), total, ownerDtos);
         context.setResponseEntity(responseEntity);
     }
 }

--
Gitblit v1.8.0