From 7e3a731b960455b16016c3c4e2e727caa8190bb0 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 01 六月 2020 12:03:04 +0800
Subject: [PATCH] 优化查询小区多条是报错问题

---
 CommunityService/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java |   70 +++++++++++++++++++++++++++++-----
 1 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/CommunityService/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java b/CommunityService/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java
index a9976df..2b3fc36 100644
--- a/CommunityService/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java
+++ b/CommunityService/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java
@@ -1,11 +1,11 @@
 package com.java110.community.dao.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.java110.common.constant.ResponseConstant;
-import com.java110.common.exception.DAOException;
-import com.java110.common.util.DateUtil;
 import com.java110.community.dao.ICommunityServiceDao;
 import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.DAOException;
+import com.java110.utils.util.DateUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -355,18 +355,18 @@
      * @return 灏忓尯淇℃伅
      * @throws DAOException
      */
-    public Map getBusinessCommunityMember(Map info) throws DAOException {
+    public List<Map> getBusinessCommunityMember(Map info) throws DAOException {
         logger.debug("鏌ヨ灏忓尯鎴愬憳鍔犲叆淇℃伅 鍏ュ弬 info : {}", info);
 
         List<Map> businessCommunityMembers = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessCommunityMember", info);
         if (businessCommunityMembers == null || businessCommunityMembers.size() == 0) {
             return null;
         }
-        if (businessCommunityMembers.size() > 1) {
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "鏍规嵁鏉′欢鏌ヨ鏈夊鏉℃暟鎹�,鏁版嵁寮傚父锛岃妫�鏌ワ細businessCommunityMember锛�" + JSONObject.toJSONString(info));
-        }
+//        if (businessCommunityMembers.size() > 1) {
+//            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "鏍规嵁鏉′欢鏌ヨ鏈夊鏉℃暟鎹�,鏁版嵁寮傚父锛岃妫�鏌ワ細businessCommunityMember锛�" + JSONObject.toJSONString(info));
+//        }
 
-        return businessCommunityMembers.get(0);
+        return businessCommunityMembers;
     }
 
     /**
@@ -377,7 +377,7 @@
      * @return 灏忓尯淇℃伅
      * @throws DAOException
      */
-    public Map getCommunityMember(Map info) throws DAOException {
+    public List<Map> getCommunityMember(Map info) throws DAOException {
         logger.debug("鏌ヨ灏忓尯鎴愬憳鍔犲叆淇℃伅 鍏ュ弬 info : {}", info);
 
         List<Map> memberCommunitys = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityMember", info);
@@ -388,7 +388,7 @@
             throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "鏍规嵁鏉′欢鏌ヨ鏈夊鏉℃暟鎹�,鏁版嵁寮傚父锛岃妫�鏌ワ細getCommunityMember锛�" + JSONObject.toJSONString(info));
         }
 
-        return memberCommunitys.get(0);
+        return memberCommunitys;
     }
 
     /**
@@ -431,5 +431,53 @@
             return 0;
         }
 
-        return Integer.parseInt(memberCommunitys.get(0).get("count").toString());    }
+        return Integer.parseInt(memberCommunitys.get(0).get("count").toString());
+    }
+
+    /**
+     * 鏌ヨ灏忓尯淇℃伅锛坕nstance锛�
+     *
+     * @param info bId 淇℃伅
+     * @return List<Map>
+     * @throws DAOException DAO寮傚父
+     */
+    @Override
+    public List<Map> getCommunityInfoNew(Map info) throws DAOException {
+        logger.debug("鏌ヨ灏忓尯淇℃伅 鍏ュ弬 info : {}", info);
+
+        List<Map> businessCommunityInfos = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityInfoNew", info);
+
+        return businessCommunityInfos;
+    }
+
+    /**
+     * 鏌ヨ灏忓尯鏁伴噺
+     *
+     * @param info 灏忓尯淇℃伅
+     * @return 灏忓尯鏁伴噺
+     */
+    @Override
+    public int queryCommunitysCount(Map info) {
+        logger.debug("鏌ヨ灏忓尯鏁版嵁 鍏ュ弬 info : {}", info);
+
+        List<Map> businessCommunityInfos = sqlSessionTemplate.selectList("communityServiceDaoImpl.queryCommunitysCount", info);
+        if (businessCommunityInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessCommunityInfos.get(0).get("count").toString());
+    }
+
+    @Override
+    public int getCommunityAttrsCount(Map info) {
+        logger.debug("鏌ヨ灏忓尯鏁版嵁 鍏ュ弬 info : {}", info);
+
+        List<Map> businessCommunityInfos = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityAttrsCount", info);
+        if (businessCommunityInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessCommunityInfos.get(0).get("count").toString());
+    }
+
 }

--
Gitblit v1.8.0