From 9219488d53d9ab234321ca1bb0b7322a9a2d1882 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期二, 08 十一月 2022 13:50:48 +0800
Subject: [PATCH] #

---
 src/main/resources/mapper/CstmrMapper.xml |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/main/resources/mapper/CstmrMapper.xml b/src/main/resources/mapper/CstmrMapper.xml
index 35ca255..8b08a70 100644
--- a/src/main/resources/mapper/CstmrMapper.xml
+++ b/src/main/resources/mapper/CstmrMapper.xml
@@ -57,8 +57,27 @@
         FROM man_cstmr mc
         LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
         WHERE 1=1
-        AND (CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
-        <if test="hostId != null and hostId != ''">
+        <choose>
+            <when test="deptId != null and deptId != ''">
+                AND (CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
+            </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>
+        <if test="hostId != null">
             and mc.host_id = #{hostId}
         </if>
         <if test="condition != null and condition != ''">
@@ -77,5 +96,8 @@
         ORDER BY mc.create_time DESC
     </select>
 
+    <update id="updateDeptIdByUserId">
+        update man_cstmr set dept_id = #{deptId} where user_id = #{userId}
+    </update>
 
 </mapper>

--
Gitblit v1.9.1