From 1c89a9d39893c18aac63aa5763b4787b65de3624 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期四, 30 五月 2024 11:28:37 +0800
Subject: [PATCH] fix:在线练习排序

---
 src/main/resources/mapper/UserMapper.xml |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml
index 7b36ba1..0d3b2e1 100644
--- a/src/main/resources/mapper/UserMapper.xml
+++ b/src/main/resources/mapper/UserMapper.xml
@@ -341,7 +341,7 @@
         WHERE
             a.deleted=0
             <if test="departmentId != null and departmentId.size() > 0">
-                AND b.department_id IN <foreach collection="departmentId" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach>
+                AND b.department_id IN <foreach collection="departmentId" item="item" open="(" separator="," close=")"> #{item} </foreach>
             </if>
             <if test="userName != null and userName != ''">
                 AND real_name LIKE concat('%',#{userName},'%')
@@ -551,18 +551,17 @@
     </select>
 
     <select id="getUserByExamByTemplateId" resultType="com.mindskip.xzs.domain.User" parameterType="com.mindskip.xzs.domain.ExamPaper">
-        <![CDATA[
-        SELECT DISTINCT
-        d.*
-        FROM
-        t_exam_templates a
-        INNER JOIN t_exam_templates_user_count b ON a.id = b.exam_templates_id and a.id = ${id}
-        LEFT JOIN t_exam_paper_answer c ON b.exam_paper_id = c.exam_paper_id AND c.create_user = b.user_id and invalid = 0
-        LEFT JOIN t_user d ON b.user_id = d.id
-        WHERE
-        ( c.id IS NULL OR ( user_score / paper_score ) < 0.6 )
-        AND b.user_id = #{createUser}
-        ]]>
+        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 = #{id})))
+        and id = #{createUser}
+    </select>
+
+    <select id="getDeptIds" resultType="integer">
+        SELECT department_id FROM t_user_department WHERE user_id = #{userId} AND dept_admin != 1
     </select>
 
 </mapper>

--
Gitblit v1.8.0