From efafaeb3ba1b38273fdcd7009beaaa41afa5a0a0 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Fri, 24 Sep 2021 11:05:49 +0800
Subject: [PATCH] 1.单位

---
 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
index 7123f03..e9e2fd8 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -122,7 +122,12 @@
     </select>
 
     <select id="selectUserPage" resultMap="userResultMap">
-        select * from blade_user where is_deleted = 0
+        select bu.* from blade_user bu
+        left join
+        blade_dept bd
+        on
+        bd.id = bu.dept_id
+        where bu.is_deleted = 0
         <if test="user.tenantId!=null and user.tenantId != ''">
             and tenant_id = #{user.tenantId}
         </if>
@@ -133,7 +138,7 @@
             and real_name like concat(concat('%', #{user.realName}),'%')
         </if>
         <if test="user.deptId!=null and user.deptId != ''">
-            and dept_id like concat(concat('%', #{user.deptId}),'%')
+            and (bd.id = #{user.deptId} or bd.parent_id = #{user.deptId})
         </if>
         <if test="user.userType!=null and user.userType != ''">
             and user_type = #{user.userType}
@@ -149,16 +154,17 @@
         </if>
         <if test="user.hold!=null and user.hold != ''">
             and hold = #{user.hold}
-        </if> <if test="user.jurisdiction!=null and user.jurisdiction != ''">
-        and jurisdiction = #{user.jurisdiction}
-    </if>
+        </if>
+        <if test="user.jurisdiction!=null and user.jurisdiction != ''">
+            and jurisdiction = #{user.jurisdiction}
+        </if>
         <if test="user.securitynumber!=null and user.securitynumber != ''">
             and securitynumber = #{user.securitynumber}
         </if>
         <if test="user.examinationType!=null and user.examinationType != ''">
             and examination_type = #{user.examinationType}
         </if>
-        ORDER BY id
+        ORDER BY bu.id
     </select>
 
     <select id="getUser" resultMap="userResultMap">
@@ -489,4 +495,13 @@
     <select id="selectCountAccount" resultType="java.lang.Integer">
         select count(*) from blade_user where account = #{account}
     </select>
+
+    <!--查询当前部门名称及父级部门名称-->
+    <select id="getDeptName" resultType="java.lang.String">
+        (select dept_name from blade_dept where id = #{deptId} and 1=1)
+        union
+        (
+            select dept_name from blade_dept where id =  (select parent_id from blade_dept where id= #{deptId} and 1=1)
+        )
+    </select>
 </mapper>

--
Gitblit v1.9.3