From 85ce0fa8006e3290447ae0e78783b353f7a3e8f6 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 17 十一月 2023 10:05:47 +0800
Subject: [PATCH] 查询条件中like语法错误修改

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml
index 46df3bd..0fee717 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml
@@ -16,6 +16,10 @@
     <!--@mbg.generated-->
     id, `name`, `header`, phone, area, color,deleted
   </sql>
+  <sql id="part_Column_List">
+    <!--@mbg.generated-->
+    id, `name`
+  </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->
     select
@@ -23,22 +27,29 @@
     from ba_block
     where id = #{id,jdbcType=BIGINT}
   </select>
-  <select id="selectTotal" parameterType="java.util.Map" resultType="java.lang.Long">
+
+  <select id="selectAll" resultMap="BaseResultMap">
+    select
+    <include refid="part_Column_List" />
+    from ba_block
+  </select>
+
+<select id="selectTotal" parameterType="java.util.Map" resultType="java.lang.Long">
     select
     count(*)
     from ba_block
-      <trim prefix="where ">
+      <trim prefix="where " suffixOverrides="and">
         <if test="name != null">
-          name like '%#{name,jdbcType=VARCHAR}%' and
+          name like concat('%', #{name}, '%') and
         </if>
         <if test="header != null">
-          header = '#{header,jdbcType=VARCHAR}' and
+          header like concat('%', #{header}, '%') and
         </if>
         <if test="phone != null">
           phone = '#{phone,jdbcType=VARCHAR}' and
         </if>
         <if test="area != null">
-          area = #{area,jdbcType=INTEGER}
+          area = #{area,jdbcType=INTEGER} and
         </if>
       </trim>
   </select>
@@ -47,9 +58,9 @@
     select
     <include refid="Base_Column_List" />
     from ba_block
-    <trim prefix="where ">
+    <trim prefix="where " suffixOverrides="and">
       <if test="name != null">
-        name like '%#{name,jdbcType=VARCHAR}%' and
+        name like concat('%', #{name}, '%') and
       </if>
       <if test="header != null">
         header = '#{header,jdbcType=VARCHAR}' and
@@ -58,7 +69,7 @@
         phone = '#{phone,jdbcType=VARCHAR}' and
       </if>
       <if test="area != null">
-        area = #{area,jdbcType=INTEGER}
+        area = #{area,jdbcType=INTEGER} and
       </if>
     </trim>
     order by id DESC

--
Gitblit v1.8.0