From afa3bc1e2f39f66f59ee9b15d6af16593acdc9a4 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期六, 02 十二月 2023 10:38:27 +0800
Subject: [PATCH] #

---
 src/main/resources/mapper/CstmrMapper.xml |  149 +++++++++++++++++++++++++++----------------------
 1 files changed, 81 insertions(+), 68 deletions(-)

diff --git a/src/main/resources/mapper/CstmrMapper.xml b/src/main/resources/mapper/CstmrMapper.xml
index 5d6d2ef..f3b9e68 100644
--- a/src/main/resources/mapper/CstmrMapper.xml
+++ b/src/main/resources/mapper/CstmrMapper.xml
@@ -103,8 +103,10 @@
             <otherwise>
                 and
                 (
-                    user_id = #{userId}
-                    or
+                    <if test="userId != null and userId != ''">
+                        user_id = #{userId} or
+                    </if>
+                    director = #{userId} or
                     mc.id in
                     (
                         select
@@ -164,10 +166,12 @@
             <otherwise>
                 and
                 (
-                user_id = #{userId}
-                or
-                director = #{userId}
-                or
+                <if test="userId != null and userId != ''">
+                    mc.user_id = #{userId}
+                    or
+                    mc.director = #{userId}
+                    or
+                </if>
                 mc.id in
                 (
                 select
@@ -230,6 +234,9 @@
                 </if>
             </otherwise>
         </choose>
+        <if test="director != null and director != ''">
+            or mc.director = #{director}
+        </if>
         ORDER BY mc.create_time DESC
     </select>
 
@@ -246,7 +253,7 @@
                 (CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
                 or
                 (
-                user_id = #{userId}
+                mc.user_id = #{userId}
                 or
                 mc.id in
                 (
@@ -262,10 +269,12 @@
             <otherwise>
                 and
                 (
-                user_id = #{userId}
-                or
-                director = #{userId}
-                or
+                <if test="userId != null and userId != ''">
+                    mc.user_id = #{userId}
+                    or
+                    mc.director = #{userId}
+                    or
+                </if>
                 mc.id in
                 (
                 select
@@ -328,6 +337,9 @@
                 </if>
             </otherwise>
         </choose>
+        <if test="director != null and director != ''">
+            or mc.director = #{director}
+        </if>
         ORDER BY mc.create_time DESC
     </select>
 
@@ -429,10 +441,12 @@
             <otherwise>
                 and
                 (
-                user_id = #{userId}
-                or
-                director = #{userId}
-                or
+                <if test="userId != null and userId != ''">
+                    mc.user_id = #{userId}
+                    or
+                    mc.director = #{userId}
+                    or
+                </if>
                 mc.id in
                 (
                 select
@@ -501,12 +515,13 @@
                 </if>
             </otherwise>
         </choose>
-
-
+        <if test="director != null and director != ''">
+            or mc.director = #{director}
+        </if>
         ORDER BY mc.create_time DESC
     </select>
 
-    <select id="listByPage3" resultMap="BaseResultMap">
+    <select id="listByPage33" resultMap="BaseResultMap">
         SELECT
         mc.*
         FROM man_cstmr mc
@@ -535,10 +550,12 @@
             <otherwise>
                 and
                 (
-                user_id = #{userId}
-                or
-                director = #{userId}
-                or
+                <if test="userId != null and userId != ''">
+                    mc.user_id = #{userId}
+                    or
+                    mc.director = #{userId}
+                    or
+                </if>
                 mc.id in
                 (
                 select
@@ -607,8 +624,9 @@
                 </if>
             </otherwise>
         </choose>
-
-
+        <if test="director != null and director != ''">
+            or mc.director = #{director}
+        </if>
         ORDER BY mc.create_time DESC
     </select>
 
@@ -619,54 +637,49 @@
         LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
         WHERE 1=1
         and director is null
-        <choose>
-            <when test="deptId != null and deptId != ''">
-                AND ((CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
-                or
-                (
-                user_id = #{userId}
-                or
-                mc.id in
-                (
-                select
-                cstmr_id
-                from man_cstmr_foll
-                where 1=1
-                and user_id = #{userId}
-                )
-                ))
-            </when>
-            <otherwise>
-                and
-                (
-                user_id = #{userId}
-                or
-                mc.id in
-                (
-                select
-                cstmr_id
-                from man_cstmr_foll
-                where 1=1
-                and user_id = #{userId}
-                )
-                )
-            </otherwise>
-        </choose>
+<!--        <choose>-->
+<!--            <when test="deptId != null and deptId != ''">-->
+<!--                AND ((CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})-->
+<!--                or-->
+<!--                (-->
+<!--                user_id = #{userId}-->
+<!--                or-->
+<!--                mc.id in-->
+<!--                (-->
+<!--                select-->
+<!--                cstmr_id-->
+<!--                from man_cstmr_foll-->
+<!--                where 1=1-->
+<!--                and user_id = #{userId}-->
+<!--                )-->
+<!--                ))-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and-->
+<!--                (-->
+<!--                <if test="userId != null and userId != ''">-->
+<!--                    user_id = #{userId}-->
+<!--                </if>-->
+<!--                <if test="userId == null or userId == ''">-->
+<!--                    user_id is not null-->
+<!--                </if>-->
+<!--                or-->
+<!--                mc.id in-->
+<!--                (-->
+<!--                select-->
+<!--                cstmr_id-->
+<!--                from man_cstmr_foll-->
+<!--                where 1=1-->
+<!--                and user_id = #{userId}-->
+<!--                )-->
+<!--                )-->
+<!--            </otherwise>-->
+<!--        </choose>-->
         <if test="hostId != null">
             and mc.host_id = #{hostId}
         </if>
         <if test="condition != null and condition != ''">
-            and (
-            mc.uuid like concat('%',#{condition},'%')
-            or mc.name like concat('%',#{condition},'%')
-            or mc.simple like concat('%',#{condition},'%')
-            or mc.rela like concat('%',#{condition},'%')
-            or mc.tel like concat('%',#{condition},'%')
-            or mc.contacts like concat('%',#{condition},'%')
-            or mc.remarks like concat('%',#{condition},'%')
-            or mc.director like concat('%',#{condition},'%')
-            or mc.addr like concat('%',#{condition},'%')
-            )
+            and mc.name like concat('%',#{condition},'%')
         </if>
         ORDER BY mc.create_time DESC
     </select>

--
Gitblit v1.9.1