From 498288ba58aaeaea0453424a8f9b8448582ff0df Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 08 十二月 2020 14:52:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/xinghong-dev'

---
 service-api/src/main/java/com/java110/api/listener/owner/QueryOwnersListener.java |   64 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/service-api/src/main/java/com/java110/api/listener/owner/QueryOwnersListener.java b/service-api/src/main/java/com/java110/api/listener/owner/QueryOwnersListener.java
index a5dd7e8..1b5744b 100644
--- a/service-api/src/main/java/com/java110/api/listener/owner/QueryOwnersListener.java
+++ b/service-api/src/main/java/com/java110/api/listener/owner/QueryOwnersListener.java
@@ -3,6 +3,8 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.java110.api.listener.AbstractServiceApiDataFlowListener;
+import com.java110.dto.basePrivilege.BasePrivilegeDto;
+import com.java110.intf.community.IMenuInnerServiceSMO;
 import com.java110.utils.constant.ServiceCodeConstant;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -18,7 +20,9 @@
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName OwnerDto
@@ -33,6 +37,9 @@
 
     @Autowired
     private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
+
+    @Autowired
+    private IMenuInnerServiceSMO menuInnerServiceSMOImpl;
 
     @Override
     public String getServiceCode() {
@@ -55,7 +62,8 @@
         //鑾峰彇璇锋眰鏁版嵁
         JSONObject reqJson = dataFlowContext.getReqJson();
         validateOwnerData(reqJson);
-
+        //鑾峰彇褰撳墠鐢ㄦ埛id
+        String userId = dataFlowContext.getUserId();
 
         if (reqJson.containsKey("name")) {
             queryByCondition(reqJson, dataFlowContext);
@@ -69,9 +77,26 @@
         //鏌ヨ鎬昏褰曟暟
         int total = ownerInnerServiceSMOImpl.queryOwnersCount(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
         apiOwnerVo.setTotal(total);
+        List<OwnerDto> ownerDtos = new ArrayList<>();
         if (total > 0) {
             List<OwnerDto> ownerDtoList = ownerInnerServiceSMOImpl.queryOwners(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
-            apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtoList, ApiOwnerDataVo.class));
+            List<Map> mark = getPrivilegeOwnerList("/roomCreateFee", userId);
+            for (OwnerDto ownerDto : ownerDtoList) {
+                //瀵逛笟涓昏韩浠借瘉鍙烽殣钘忓鐞�
+                String idCard = ownerDto.getIdCard();
+                if (mark.size() == 0 && idCard != null && !idCard.equals("")) {
+                    idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16);
+                    ownerDto.setIdCard(idCard);
+                }
+                //瀵逛笟涓绘墜鏈哄彿闅愯棌澶勭悊
+                String link = ownerDto.getLink();
+                if (mark.size() == 0 && link != null && !link.equals("")) {
+                    link = link.substring(0, 3) + "****" + link.substring(7);
+                    ownerDto.setLink(link);
+                }
+                ownerDtos.add(ownerDto);
+            }
+            apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtos, ApiOwnerDataVo.class));
         }
 
         apiOwnerVo.setRecords((int) Math.ceil((double) total / (double) row));
@@ -88,14 +113,32 @@
      * @param dataFlowContext 涓婁笅鏂�
      */
     private void queryByCondition(JSONObject reqJson, DataFlowContext dataFlowContext) {
-
+        //鑾峰彇褰撳墠鐢ㄦ埛id
+        String userId = dataFlowContext.getUserId();
         int row = reqJson.getInteger("row");
         ApiOwnerVo apiOwnerVo = new ApiOwnerVo();
         int total = ownerInnerServiceSMOImpl.queryOwnerCountByCondition(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
         apiOwnerVo.setTotal(total);
+        List<OwnerDto> ownerDtos = new ArrayList<>();
         if (total > 0) {
             List<OwnerDto> ownerDtoList = ownerInnerServiceSMOImpl.queryOwnersByCondition(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
-            apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtoList, ApiOwnerDataVo.class));
+            List<Map> mark = getPrivilegeOwnerList("/roomCreateFee", userId);
+            for (OwnerDto ownerDto : ownerDtoList) {
+                //瀵逛笟涓昏韩浠借瘉鍙烽殣钘忓鐞�
+                String idCard = ownerDto.getIdCard();
+                if (mark.size() == 0 && idCard != null && !idCard.equals("")) {
+                    idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16);
+                    ownerDto.setIdCard(idCard);
+                }
+                //瀵逛笟涓绘墜鏈哄彿闅愯棌澶勭悊
+                String link = ownerDto.getLink();
+                if (mark.size() == 0 && link != null && !link.equals("")) {
+                    link = link.substring(0, 3) + "****" + link.substring(7);
+                    ownerDto.setLink(link);
+                }
+                ownerDtos.add(ownerDto);
+            }
+            apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtos, ApiOwnerDataVo.class));
         }
 
         apiOwnerVo.setRecords((int) Math.ceil((double) total / (double) row));
@@ -132,4 +175,17 @@
     public void setOwnerInnerServiceSMOImpl(IOwnerInnerServiceSMO ownerInnerServiceSMOImpl) {
         this.ownerInnerServiceSMOImpl = ownerInnerServiceSMOImpl;
     }
+
+    /**
+     * 鑴辨晱澶勭悊
+     *
+     * @return
+     */
+    public List<Map> getPrivilegeOwnerList(String resource, String userId) {
+        BasePrivilegeDto basePrivilegeDto = new BasePrivilegeDto();
+        basePrivilegeDto.setResource(resource);
+        basePrivilegeDto.setUserId(userId);
+        List<Map> privileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto);
+        return privileges;
+    }
 }

--
Gitblit v1.8.0