From df774e4fd262b0a39e52152f166ccddb2aa9f90e Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 11 十月 2020 23:44:43 +0800
Subject: [PATCH] 优化代码
---
java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml | 95 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 85 insertions(+), 10 deletions(-)
diff --git a/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
index 4d7f0f0..9115934 100644
--- a/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
@@ -315,9 +315,16 @@
<if test="memberId != null and memberId != '' and needCommunityInfo == true">
AND ms.`community_id` = msc.`community_id`
and msc.member_id = #{memberId}
+ and msc.status_cd = '0'
</if>
<if test="memberId != null and memberId != '' and needCommunityInfo == false">
and ms.member_id = #{memberId}
+ </if>
+ <if test="subMemberId != null and subMemberId != ''">
+ and ms.member_id = #{subMemberId}
+ </if>
+ <if test="noAuditEnterCommunity == true">
+ and ms.member_type_cd not in ('390001200003','390001200005','390001200000')
</if>
<if test="memberTypeCd != null and memberTypeCd != ''">
and ms.member_type_cd = #{memberTypeCd}
@@ -329,6 +336,13 @@
<if test="communityId != null and communityId != ''">
and ms.community_id = #{communityId}
</if>
+ <if test="communityName != null and communityName != '' and needCommunityInfo == true">
+ and sc.name like concat('%',#{communityName},'%')
+ </if>
+ <if test="needCommunityInfo == true">
+ group by ms.community_id
+ </if>
+ order by ms.create_time desc
<if test="page != -1 and page != null">
limit #{page},#{row}
</if>
@@ -355,7 +369,7 @@
<!-- 鏌ヨ灏忓尯鎴愬憳 add by wuxw 2018-07-03 -->
<select id="getCommunityMemberCount" parameterType="Map" resultType="Map">
- select count(1) count
+ select ms.community_id,count(1) count
from s_community_member ms
<if test="needCommunityInfo == true">
,s_community sc,
@@ -380,8 +394,20 @@
<if test="memberId != null and memberId != '' and needCommunityInfo == true">
AND ms.`community_id` = msc.`community_id`
and msc.member_id = #{memberId}
+ and msc.status_cd = '0'
</if>
- <if test="memberId != null andull
+ <if test="memberId != null and memberId != '' and needCommunityInfo == false">
+ and ms.member_id = #{memberId}
+ </if>
+
+ <if test="subMemberId != null and subMemberId != ''">
+ and ms.member_id = #{subMemberId}
+ </if>
+
+ <if test="noAuditEnterCommunity == true">
+ and ms.member_type_cd not in ('390001200003','390001200005','390001200000')
+ </if>
+
<if test="memberTypeCd != null and memberTypeCd != ''">
and ms.member_type_cd = #{memberTypeCd}
</if>
@@ -389,9 +415,22 @@
and ms.audit_status_cd = #{auditStatusCd}
</if>
+ <if test="auditStatusCds != null and auditStatusCds != null">
+ and ms.audit_status_cd in
+ <foreach collection="auditStatusCds" item="item" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
+ </if>
<if test="communityId != null and communityId != ''">
and ms.community_id = #{communityId}
</if>
+ <if test="communityName != null and communityName != '' and needCommunityInfo == true">
+ and sc.name like concat('%',#{communityName},'%')
+ </if>
+ <if test="needCommunityInfo == true">
+ group by ms.community_id
+ </if>
+
</select>
<!-- 鏌ヨ灏忓尯淇℃伅 add by wuxw 2018-07-03 -->
@@ -406,12 +445,15 @@
THEN '瀹℃牳瀹屾垚'
ELSE
'瀹℃牳鎷掔粷'
- END) stateName
- from s_community t
+ END) stateName,ca.area_code areaCode,ca.area_name areaName,
+ ca.parent_area_code parentAreaCode,ca.parent_area_name parentAreaName
+ from s_community t,city_area ca
<if test="memberId !=null and memberId !=''">
,s_community_member cm
</if>
where 1 =1
+ and t.city_code = ca.area_code
+ and ca.status_cd = '0'
<if test="address !=null and address != ''">
and t.address= #{address}
</if>
@@ -422,13 +464,19 @@
and t.city_code= #{cityCode}
</if>
<if test="name !=null and name != ''">
- and t.name= #{name}
+ and t.name like concat('%',#{name},'%')
</if>
<if test="statusCd !=null and statusCd != ''">
and t.status_cd= #{statusCd}
</if>
<if test="communityId !=null and communityId != ''">
and t.community_id= #{communityId}
+ </if>
+ <if test="communityIds !=null">
+ and t.community_id in
+ <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
</if>
<if test="bId !=null and bId != ''">
and t.b_id= #{bId}
@@ -447,6 +495,16 @@
and cm.member_id = #{memberId}
and cm.status_cd = '0'
</if>
+ <if test="memberId !=null and memberId !='' and auditStatusCd != null and auditStatusCd !=''">
+ and cm.audit_status_cd = #{auditStatusCd}
+ </if>
+ <if test="notInCommunityId != null ">
+ and t.community_id not in
+ <foreach collection="notInCommunityId" item="item" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
+ </if>
+ group by t.community_id
<if test="page != -1 and page != null ">
limit #{page}, #{row}
</if>
@@ -457,12 +515,14 @@
<!-- 鏌ヨ灏忓尯鏁伴噺 add by wuxw 2018-07-03 -->
<select id="queryCommunitysCount" parameterType="Map" resultType="Map">
- select count(1) count
- from s_community t
+ select count(DISTINCT(t.community_id)) count
+ from s_community t,city_area ca
<if test="memberId !=null and memberId !=''">
,s_community_member cm
</if>
where 1 =1
+ and t.city_code = ca.area_code
+ and ca.status_cd = '0'
<if test="address !=null and address != ''">
and t.address= #{address}
</if>
@@ -473,13 +533,19 @@
and t.city_code= #{cityCode}
</if>
<if test="name !=null and name != ''">
- and t.name= #{name}
+ and t.name like concat('%',#{name},'%')
</if>
<if test="statusCd !=null and statusCd != ''">
and t.status_cd= #{statusCd}
</if>
<if test="communityId !=null and communityId != ''">
and t.community_id= #{communityId}
+ </if>
+ <if test="communityIds !=null">
+ and t.community_id in
+ <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
</if>
<if test="bId !=null and bId != ''">
and t.b_id= #{bId}
@@ -495,8 +561,17 @@
</if>
<if test="memberId !=null and memberId !=''">
and cm.community_id = t.community_id
- and cm.member_id = #{memberId}
- and cm.status_cd = '0'
+ and cm.member_id = #{memberId}
+ and cm.status_cd = '0'
+ </if>
+ <if test="memberId !=null and memberId !='' and auditStatusCd != null and auditStatusCd !=''">
+ and cm.audit_status_cd = #{auditStatusCd}
+ </if>
+ <if test="notInCommunityId != null ">
+ and t.community_id not in
+ <foreach collection="notInCommunityId" item="item" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
</if>
--
Gitblit v1.8.0