From 05d651ca0168025ec451702f1df88dab4f2a9559 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期五, 10 五月 2024 17:58:19 +0800
Subject: [PATCH] feat:新增补考按钮
---
src/main/resources/mapper/DepartmentMapper.xml | 56 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/src/main/resources/mapper/DepartmentMapper.xml b/src/main/resources/mapper/DepartmentMapper.xml
index 5eee8cd..ea69ef0 100644
--- a/src/main/resources/mapper/DepartmentMapper.xml
+++ b/src/main/resources/mapper/DepartmentMapper.xml
@@ -13,8 +13,8 @@
</sql>
<insert id="add" parameterType="com.mindskip.xzs.domain.Department" useGeneratedKeys="true" keyProperty="id">
- insert into t_department (name, admin_id, deleted)
- values (#{name,jdbcType=VARCHAR}, {#{adminId}, #{deleted,jdbcType=VARCHAR})
+ insert into t_department (name, deleted)
+ values (#{name,jdbcType=VARCHAR}, #{deleted,jdbcType=VARCHAR})
</insert>
<update id="update" parameterType="com.mindskip.xzs.domain.Department">
@@ -36,39 +36,56 @@
<select id="gets" resultMap="BaseResultMap">
SELECT
td.id,
- td.name,
- td.admin_id as adminId,
- tu.real_name as adminName
+ td.name
FROM
t_department td
- LEFT JOIN t_user tu ON td.admin_id = tu.id AND tu.deleted = 0
WHERE
td.deleted = 0
+ <if test="deptId != null">
+ AND td.id = #{deptId}
+ </if>
</select>
<select id="getById" resultMap="BaseResultMap">
SELECT
td.id,
- td.name,
- td.admin_id as adminId,
- tu.real_name as adminName
+ td.name
FROM
t_department td
- LEFT JOIN t_user tu ON td.admin_id = tu.id AND tu.deleted = 0
WHERE
td.id = #{id} AND td.deleted = 0
</select>
- <select id="page" resultType="com.mindskip.xzs.viewmodel.admin.department.DepartmentResponseVM"
+ <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
td.id,
- td.name,
- td.admin_id as adminId,
- tu.real_name as adminName
+ td.name
FROM
t_department td
- LEFT JOIN t_user tu ON td.admin_id = tu.id AND tu.deleted = 0
<where>
AND td.deleted = 0
<if test="id != null ">
@@ -93,4 +110,13 @@
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