Browse Source

修改SQL语句

wanghui 8 years ago
parent
commit
9f855a3ed3
1 changed files with 72 additions and 70 deletions
  1. 72 70
      src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

+ 72 - 70
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -15,28 +15,28 @@
 				from user
 					where type = 0
 					<if test="aid != null and aid !=''">
-						and a.aid = #{aid,jdbcType=VARCHAR}
+						and aid = #{aid,jdbcType=VARCHAR}
 					</if>
 					<if test="shareType != null and shareType !=''">
-						and a.share_type = #{shareType,jdbcType=VARCHAR}
+						and share_type = #{shareType,jdbcType=VARCHAR}
 					</if>				
 					<if test="status != null">
-						and a.status = #{status,jdbcType=INTEGER}
+						and status = #{status,jdbcType=INTEGER}
 					</if>
 					<if test="serviceCertification != null">
-						and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+						and service_certification = #{serviceCertification,jdbcType=INTEGER}
 					</if>
 					<if test="userCertification != null">
-						and a.user_certification = #{userCertification,jdbcType=INTEGER}
+						and user_certification = #{userCertification,jdbcType=INTEGER}
 					</if>
 					<if test="currentMemberStatus != null">
-						and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+						and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 					</if>
 					<if test="startDate != null and startDate != ''">
-				   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				   	<if test="endDate != null and endDate != ''">
-				   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				)as a inner join user_identity b on a.id = b.uid 
 				left join district_glossory dg1 on b.province = dg1.id 
@@ -44,7 +44,7 @@
 				left join district_glossory dg3 on b.area = dg3.id
 				left join industry_category c on b.industry = c.id 
 				where 1=1 
-				<if test="name != null and name''">
+				<if test="name != null and name !=''">
 					and b.username = #{name,jdbcType=VARCHAR}
 				</if>
 				<if test="province != null">
@@ -72,28 +72,28 @@
 				from user
 					where type = 1
 					<if test="aid != null and aid !=''">
-						and a.aid = #{aid,jdbcType=VARCHAR}
+						and aid = #{aid,jdbcType=VARCHAR}
 					</if>
 					<if test="shareType != null and shareType !=''">
-						and a.share_type = #{shareType,jdbcType=VARCHAR}
+						and share_type = #{shareType,jdbcType=VARCHAR}
 					</if>				
 					<if test="status != null">
-						and a.status = #{status,jdbcType=INTEGER}
+						and status = #{status,jdbcType=INTEGER}
 					</if>
 					<if test="serviceCertification != null">
-						and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+						and service_certification = #{serviceCertification,jdbcType=INTEGER}
 					</if>
 					<if test="userCertification != null">
-						and a.user_certification = #{userCertification,jdbcType=INTEGER}
+						and user_certification = #{userCertification,jdbcType=INTEGER}
 					</if>
 					<if test="currentMemberStatus != null">
-						and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+						and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 					</if>
 					<if test="startDate != null and startDate != ''">
-				   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				   	<if test="endDate != null and endDate != ''">
-				   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				)as a inner join organization_identity b on a.id = b.uid 
 				left join district_glossory dg1 on b.licence_province = dg1.id 
@@ -101,7 +101,7 @@
 				left join district_glossory dg3 on b.licence_area = dg3.id
 				left join industry_category c on b.industry = c.id 
 				where 1=1
-				<if test="name != null and name''">
+				<if test="name != null and name != ''">
 					and b.unit_name = #{name,jdbcType=VARCHAR}
 				</if>
 				<if test="province != null">
@@ -118,6 +118,7 @@
 				</if>
 			</when>
 			<otherwise>
+			select * from (
 				select  
 					a.id as uid,a.type,a.status, a.create_time as createTime,a.service_certification as serviceCertification,
 					a.user_certification as userCertification,a.current_member_status as currentMemberStatus,
@@ -129,28 +130,28 @@
 				from user
 					where type = 0
 					<if test="aid != null and aid !=''">
-						and a.aid = #{aid,jdbcType=VARCHAR}
+						and aid = #{aid,jdbcType=VARCHAR}
 					</if>
 					<if test="shareType != null and shareType !=''">
-						and a.share_type = #{shareType,jdbcType=VARCHAR}
+						and share_type = #{shareType,jdbcType=VARCHAR}
 					</if>					
 					<if test="status != null">
-						and a.status = #{status,jdbcType=INTEGER}
+						and status = #{status,jdbcType=INTEGER}
 					</if>
 					<if test="serviceCertification != null">
-						and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+						and service_certification = #{serviceCertification,jdbcType=INTEGER}
 					</if>
 					<if test="userCertification != null">
-						and a.user_certification = #{userCertification,jdbcType=INTEGER}
+						and user_certification = #{userCertification,jdbcType=INTEGER}
 					</if>
 					<if test="currentMemberStatus != null">
-						and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+						and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 					</if>
 					<if test="startDate != null and startDate != ''">
-				   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				   	<if test="endDate != null and endDate != ''">
-				   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				)as a inner join user_identity b on a.id = b.uid 
 				left join district_glossory dg1 on b.province = dg1.id 
@@ -158,7 +159,7 @@
 				left join district_glossory dg3 on b.area = dg3.id
 				left join industry_category c on b.industry = c.id 
 				where 1=1 
-				<if test="name != null and name''">
+				<if test="name != null and name != ''">
 					and b.username = #{name,jdbcType=VARCHAR}
 				</if>
 				<if test="province != null">
@@ -185,28 +186,28 @@
 				from user
 					where type = 1
 					<if test="aid != null and aid !=''">
-						and a.aid = #{aid,jdbcType=VARCHAR}
+						and aid = #{aid,jdbcType=VARCHAR}
 					</if>		
 					<if test="shareType != null and shareType !=''">
-						and a.share_type = #{shareType,jdbcType=VARCHAR}
+						and share_type = #{shareType,jdbcType=VARCHAR}
 					</if>			
 					<if test="status != null">
-						and a.status = #{status,jdbcType=INTEGER}
+						and status = #{status,jdbcType=INTEGER}
 					</if>
 					<if test="serviceCertification != null">
-						and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+						and service_certification = #{serviceCertification,jdbcType=INTEGER}
 					</if>
 					<if test="userCertification != null">
-						and a.user_certification = #{userCertification,jdbcType=INTEGER}
+						and user_certification = #{userCertification,jdbcType=INTEGER}
 					</if>
 					<if test="currentMemberStatus != null">
-						and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+						and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 					</if>
 					<if test="startDate != null and startDate != ''">
-				   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				   	<if test="endDate != null and endDate != ''">
-				   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+				   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 				   	</if>
 				)as a inner join organization_identity b on a.id = b.uid 
 				left join district_glossory dg1 on b.licence_province = dg1.id 
@@ -214,7 +215,7 @@
 				left join district_glossory dg3 on b.licence_area = dg3.id
 				left join industry_category c on b.industry = c.id 
 				where 1=1
-				<if test="name != null and name''">
+				<if test="name != null and name != ''">
 					and b.unit_name = #{name,jdbcType=VARCHAR}
 				</if>
 				<if test="province != null">
@@ -228,10 +229,11 @@
 				</if>
 				<if test="industry != null">
 					and b.industry = #{industry,jdbcType=INTEGER}
-				</if>		
+				</if>	
+			)y	
 			</otherwise>
 		</choose>
-		order by a.create_time desc
+		order by createTime desc
 		<if test="page_sql!=null">
 			${page_sql}
 		</if>
@@ -247,28 +249,28 @@
 					from user
 						where type = 0 
 						<if test="aid != null and aid !=''">
-							and a.aid = #{aid,jdbcType=VARCHAR}
+							and aid = #{aid,jdbcType=VARCHAR}
 						</if>	
 						<if test="shareType != null and shareType !=''">
-							and a.share_type = #{shareType,jdbcType=VARCHAR}
+							and share_type = #{shareType,jdbcType=VARCHAR}
 						</if>				
 						<if test="status != null">
-							and a.status = #{status,jdbcType=INTEGER}
+							and status = #{status,jdbcType=INTEGER}
 						</if>
 						<if test="serviceCertification != null">
-							and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+							and service_certification = #{serviceCertification,jdbcType=INTEGER}
 						</if>
 						<if test="userCertification != null">
-							and a.user_certification = #{userCertification,jdbcType=INTEGER}
+							and user_certification = #{userCertification,jdbcType=INTEGER}
 						</if>
 						<if test="currentMemberStatus != null">
-							and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+							and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 						</if>
 						<if test="startDate != null and startDate != ''">
-					   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+					   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 					   	</if>
 					   	<if test="endDate != null and endDate != ''">
-					   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+					   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 					   	</if>
 					)as a inner join user_identity b on a.id = b.uid 	
 				where 1=1
@@ -297,28 +299,28 @@
 					from user
 						where type = 1
 						<if test="aid != null and aid !=''">
-							and a.aid = #{aid,jdbcType=VARCHAR}
+							and aid = #{aid,jdbcType=VARCHAR}
 						</if>		
 						<if test="shareType != null and shareType !=''">
-							and a.share_type = #{shareType,jdbcType=VARCHAR}
+							and share_type = #{shareType,jdbcType=VARCHAR}
 						</if>		
 						<if test="status != null">
-							and a.status = #{status,jdbcType=INTEGER}
+							and status = #{status,jdbcType=INTEGER}
 						</if>
 						<if test="serviceCertification != null">
-							and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+							and service_certification = #{serviceCertification,jdbcType=INTEGER}
 						</if>
 						<if test="userCertification != null">
-							and a.user_certification = #{userCertification,jdbcType=INTEGER}
+							and user_certification = #{userCertification,jdbcType=INTEGER}
 						</if>
 						<if test="currentMemberStatus != null">
-							and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+							and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 						</if>
 						<if test="startDate != null and startDate != ''">
-					   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+					   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 					   	</if>
 					   	<if test="endDate != null and endDate != ''">
-					   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+					   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 					   	</if>
 					)as a inner join organization_identity b on a.id = b.uid
 				where 1=1
@@ -349,28 +351,28 @@
 						from user
 							where type = 0 
 							<if test="aid != null and aid !=''">
-								and a.aid = #{aid,jdbcType=VARCHAR}
+								and aid = #{aid,jdbcType=VARCHAR}
 							</if>	
 							<if test="shareType != null and shareType !=''">
-								and a.share_type = #{shareType,jdbcType=VARCHAR}
+								and share_type = #{shareType,jdbcType=VARCHAR}
 							</if>				
 							<if test="status != null">
-								and a.status = #{status,jdbcType=INTEGER}
+								and status = #{status,jdbcType=INTEGER}
 							</if>
 							<if test="serviceCertification != null">
-								and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+								and service_certification = #{serviceCertification,jdbcType=INTEGER}
 							</if>
 							<if test="userCertification != null">
-								and a.user_certification = #{userCertification,jdbcType=INTEGER}
+								and user_certification = #{userCertification,jdbcType=INTEGER}
 							</if>
 							<if test="currentMemberStatus != null">
-								and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+								and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 							</if>
 							<if test="startDate != null and startDate != ''">
-						   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+						   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 						   	</if>
 						   	<if test="endDate != null and endDate != ''">
-						   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+						   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 						   	</if>
 						)as a inner join user_identity b on a.id = b.uid 	
 					where 1=1
@@ -398,28 +400,28 @@
 						from user
 							where type = 1
 							<if test="aid != null and aid !=''">
-								and a.aid = #{aid,jdbcType=VARCHAR}
+								and aid = #{aid,jdbcType=VARCHAR}
 							</if>	
 							<if test="shareType != null and shareType !=''">
-								and a.share_type = #{shareType,jdbcType=VARCHAR}
+								and share_type = #{shareType,jdbcType=VARCHAR}
 							</if>				
 							<if test="status != null">
-								and a.status = #{status,jdbcType=INTEGER}
+								and status = #{status,jdbcType=INTEGER}
 							</if>
 							<if test="serviceCertification != null">
-								and a.service_certification = #{serviceCertification,jdbcType=INTEGER}
+								and service_certification = #{serviceCertification,jdbcType=INTEGER}
 							</if>
 							<if test="userCertification != null">
-								and a.user_certification = #{userCertification,jdbcType=INTEGER}
+								and user_certification = #{userCertification,jdbcType=INTEGER}
 							</if>
 							<if test="currentMemberStatus != null">
-								and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
+								and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
 							</if>
 							<if test="startDate != null and startDate != ''">
-						   	 	and  a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+						   	 	and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 						   	</if>
 						   	<if test="endDate != null and endDate != ''">
-						   	 	and  a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+						   	 	and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 						   	</if>
 						)as a inner join organization_identity b on a.id = b.uid
 					where 1=1