From 05caa47bb77fdf4012067e159432defa5e38368e Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期五, 12 七月 2024 18:26:38 +0800 Subject: [PATCH] 设置可管理派出所三级单位 --- src/main/resources/mapper/UserMapper.xml | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index c6f89ad..099b1d3 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -543,10 +543,19 @@ <select id="getDeptAdmins" resultType="com.mindskip.xzs.domain.Department" parameterType="java.lang.Integer"> <if test="id != null"> - select a.id, a.name from t_department a inner join t_user_department b on a.id = b.department_id where a.deleted = 0 and b.dept_admin = 1 and b.user_id = #{id} order by a.id desc + WITH RECURSIVE temp_table AS ( + select a.id, a.name, a.parent_id from t_department a inner join t_user_department b on a.id = b.department_id where a.deleted = 0 and b.dept_admin = 1 and b.user_id = #{id} + UNION ALL + SELECT + so.id, so.name, so.parent_id FROM t_department so INNER JOIN temp_table tb ON so.parent_id = tb.id + ) + SELECT + id, name, parent_id + FROM + temp_table </if> <if test="id == null"> - select a.id, a.name from t_department a where a.deleted = 0 order by a.id desc + select a.id, a.name, a.parent_id from t_department a where a.deleted = 0 order by a.id </if> </select> @@ -564,4 +573,26 @@ SELECT department_id FROM t_user_department WHERE user_id = #{userId} AND dept_admin != 1 </select> + <select id="getFailExamUser" resultType="com.mindskip.xzs.domain.User"> + <![CDATA[ + SELECT + DISTINCT d.id, d.real_name + FROM t_exam_paper a + LEFT JOIN t_exam_paper_user b ON a.id = b.exam_paper_id AND b.deleted = 0 + LEFT JOIN t_exam_paper_answer c ON a.id = c.exam_paper_id AND c.create_user = b.user_id + LEFT JOIN t_user d ON b.user_id = d.id + WHERE a.id = #{examPaperId} + AND (c.id IS NULL OR (user_score / paper_score) < 0.6) + ]]> + </select> + + <select id="getFailTemplateUser" resultType="com.mindskip.xzs.domain.User"> + SELECT * + FROM t_user + WHERE id IN + (SELECT user_id FROM t_exam_templates_user WHERE templates_id = #{id} AND user_id NOT IN + (SELECT create_user FROM t_exam_paper_answer WHERE (user_score / paper_score) > 0.6 AND (invalid = 0 OR invalid IS NULL) AND exam_paper_id IN + (SELECT exam_paper_id FROM t_exam_templates_user_count WHERE exam_templates_id = #{templateId}))) + </select> + </mapper> -- Gitblit v1.8.0