From 2e830efbe694a3d328251b41690dc685a6e080ea Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期一, 27 五月 2024 09:51:30 +0800
Subject: [PATCH] feat:修改用户时返回密码
---
src/main/resources/mapper/DepartmentMapper.xml | 86 +++++++++++++++++++++++++++++++++++--------
1 files changed, 70 insertions(+), 16 deletions(-)
diff --git a/src/main/resources/mapper/DepartmentMapper.xml b/src/main/resources/mapper/DepartmentMapper.xml
index 7146268..bd448a9 100644
--- a/src/main/resources/mapper/DepartmentMapper.xml
+++ b/src/main/resources/mapper/DepartmentMapper.xml
@@ -23,6 +23,9 @@
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
+ <if test="adminId != null">
+ admin_id = #{adminId},
+ </if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=VARCHAR},
</if>
@@ -31,38 +34,89 @@
</update>
<select id="gets" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from t_department where deleted=0
+ SELECT
+ td.id,
+ td.name
+ FROM
+ t_department td
+ WHERE
+ td.deleted = 0
+ <if test="deptId != null and deptId.size() > 0">
+ AND td.id in <foreach collection="deptId" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach>
+ </if>
</select>
<select id="getById" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from t_department where deleted=0
- and id = #{id}
+ SELECT
+ td.id,
+ td.name
+ FROM
+ t_department td
+ WHERE
+ td.id = #{id} AND td.deleted = 0
</select>
- <select id="page" resultMap="BaseResultMap"
+ <resultMap id="pageResult" type="com.mindskip.xzs.viewmodel.admin.department.DepartmentResponseVM">
+ <id column="id" property="id"/>
+ <result column="name" property="name"/>
+ <collection column="id" property="adminIds" ofType="integer" select="selectUserIdsByDeptId"></collection>
+ <collection column="id" property="adminNames" ofType="integer" select="selectUserNamesByDeptId"></collection>
+ </resultMap>
+
+ <select id="selectUserIdsByDeptId" resultType="integer">
+ SELECT
+ tu.id
+ FROM
+ t_user_department tud
+ INNER JOIN t_user tu ON tud.user_id = tu.id AND tud.department_id = #{deptId} AND tu.status = 1 AND deleted = 0 AND tud.dept_admin = 1
+ </select>
+
+ <select id="selectUserNamesByDeptId" resultType="string">
+ SELECT
+ tu.real_name
+ FROM
+ t_user_department tud
+ INNER JOIN t_user tu ON tud.user_id = tu.id AND tud.department_id = #{deptId} AND tu.status = 1 AND deleted = 0 AND tud.dept_admin = 1
+ </select>
+
+ <select id="page" resultMap="pageResult"
parameterType="com.mindskip.xzs.viewmodel.admin.department.DepartmentResponseVM">
SELECT
- <include refid="Base_Column_List"/>
- FROM t_department
+ td.id,
+ td.name
+ FROM
+ t_department td
<where>
- and deleted=0
+ AND td.deleted = 0
<if test="id != null ">
- and id= #{id}
+ AND td.id= #{id}
</if>
<if test="name != null ">
- and name like concat('%',#{name},'%')
+ AND td.name like concat('%',#{name},'%')
</if>
</where>
</select>
<select id="getName" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from t_department where deleted=0 and name = #{name}
+ SELECT
+ td.id,
+ td.name,
+ td.admin_id as adminId,
+ tu.real_name as adminName
+ FROM
+ t_department td
+ LEFT JOIN t_user tu ON td.admin_id = tu.id AND tu.deleted = 0
+ WHERE
+ td.name = #{name} AND td.deleted = 0
</select>
+
+ <select id="selectByAdminId" resultType="integer">
+ SELECT id FROM t_department WHERE admin_id = #{userId} AND deleted = 0
+ </select>
+
+ <select id="countByAdminId" resultType="integer">
+ SELECT count(*) FROM t_department WHERE admin_id = #{userId} AND deleted = 0 AND id != #{id}
+ </select>
+
</mapper>
--
Gitblit v1.8.0