From 044e365bf44a2de99b61f5da21f9729e34e4f93f Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 18 十一月 2023 09:52:14 +0800
Subject: [PATCH] 修改查询农户sql语句

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaClientMapper.xml |   48 ++++++++++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaClientMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaClientMapper.xml
index 0a73af3..c5a0f21 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaClientMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaClientMapper.xml
@@ -19,8 +19,8 @@
     <result column="district" jdbcType="VARCHAR" property="district" />
     <result column="address" jdbcType="VARCHAR" property="address" />
     <result column="remark" jdbcType="VARCHAR" property="remark" />
-    <result column="disabled" jdbcType="TINYINT" property="disabled" />
-    <result column="deleted" jdbcType="TINYINT" property="deleted" />
+    <result property="disabled" column="disabled" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.common.mybatis.envm.Disabled"/>
+    <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.common.mybatis.envm.Deleted"/>
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
@@ -29,8 +29,8 @@
   </sql>
   <sql id="part_Column_List">
     <!--@mbg.generated-->
-    id, countyId, townId, villageId, blockId, divideId, typeId, `name`, num, phone, idCard, area, district,address, remark,
-    disabled
+      ${alias}.id, ${alias}.countyId, ${alias}.townId, ${alias}.villageId, ${alias}.blockId, ${alias}.divideId, ${alias}.typeId, ${alias}.name, ${alias}.num, ${alias}.phone, ${alias}.idCard, ${alias}.area, ${alias}.district,${alias}.address, ${alias}.remark,
+      ${alias}.disabled
   </sql>
 
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@@ -49,38 +49,46 @@
     <select id="selectTotal" parameterType="java.util.Map" resultType="java.lang.Long">
         select
         count(*)
-        from ba_client
-        where deleted != 1
+        from ba_client bc
+        left join ba_block bbk on bc.blockId = bbk.id
+        left join ba_client_type bct on bc.typeId = bct.id
+        where bc.deleted != 1
         <trim prefix="and" suffixOverrides="and">
             <if test="countyId != null">
-                countyId = #{countyId,jdbcType=BIGINT} and
+                bc.countyId = #{countyId,jdbcType=BIGINT} and
             </if>
             <if test="townId != null">
-                townId = #{townId,jdbcType=BIGINT} and
+                bc.townId = #{townId,jdbcType=BIGINT} and
             </if>
             <if test="villageId != null">
-                villageId = #{villageId,jdbcType=BIGINT} and
+                bc.villageId = #{villageId,jdbcType=BIGINT} and
             </if>
             <if test="blockId != null">
-                blockId = #{blockId,jdbcType=BIGINT} and
+                bc.blockId = #{blockId,jdbcType=BIGINT} and
             </if>
             <if test="name != null">
-                name like concat('%', #{name}, '%') and
+                bc.name like concat('%', #{name}, '%') and
             </if>
             <if test="num != null">
-                num = '#{num,jdbcType=VARCHAR}' and
+                bc.num = '#{num,jdbcType=VARCHAR}' and
             </if>
             <if test="phone != null">
-                phone = '#{phone,jdbcType=VARCHAR}' and
+                bc.phone = '#{phone,jdbcType=VARCHAR}' and
             </if>
         </trim>
     </select>
     <select id="selectSome" parameterType="java.util.Map" resultMap="BaseResultMap">
         <!--@mbg.generated-->
         select
-        <include refid="part_Column_List" />
-        from ba_client
-        where deleted != 1
+        <include refid="part_Column_List" >
+            <property name="alias" value="bc"/>
+        </include>,
+        bbk.name blockName,
+        bct.name typeName
+        from ba_client bc
+        left join ba_block bbk on bc.blockId = bbk.id
+        left join ba_client_type bct on bc.typeId = bct.id
+        where bc.deleted != 1
         <trim prefix="and" suffixOverrides="and">
             <if test="countyId != null">
                 countyId = #{countyId,jdbcType=BIGINT} and
@@ -95,16 +103,16 @@
                 blockId = #{blockId,jdbcType=BIGINT} and
             </if>
             <if test="name != null">
-                name like concat('%', #{name}, '%') and
+                bc.name like concat('%', #{name}, '%') and
             </if>
             <if test="num != null">
-                num = '#{num,jdbcType=VARCHAR}' and
+                bc.num = '#{num,jdbcType=VARCHAR}' and
             </if>
             <if test="phone != null">
-                phone = '#{phone,jdbcType=VARCHAR}' and
+                bc.phone = '#{phone,jdbcType=VARCHAR}' and
             </if>
         </trim>
-        order by id DESC
+        order by bc.id DESC
         <trim prefix="limit " >
             <if test="start != null and count != null">
                 #{start}, #{count}

--
Gitblit v1.8.0