Forráskód Böngészése

考试通过判断

yangfeng 1 éve
szülő
commit
1507b9a7cf

+ 19 - 13
web/src/main/java/com/ynfy/buss/exam/exam/mapper/xml/ExamMapper.xml

@@ -79,7 +79,8 @@
     <select id="selectExamList"  resultType="com.ynfy.buss.exam.exam.entity.Exam">
         SELECT
             tmp1.* ,
-            tmp2.try_count
+            tmp2.try_count,
+            u.passed
         FROM
         (
             SELECT
@@ -108,18 +109,23 @@
                 </when>
             </choose>
         ) tmp1
-        LEFT JOIN (
-            SELECT
-                exam_id,
-                COUNT ( * ) AS try_count
-            FROM
-                user_exam uer
-            WHERE
-                uer.user_id = #{user.id}
-            GROUP BY
-                exam_id
-        ) tmp2
-        ON tmp1.ID = tmp2.exam_id
+        <choose>
+            <when test="user!=null and user.id!=null and user.id!=''">
+                LEFT JOIN (
+                    SELECT
+                        exam_id,
+                        COUNT ( * ) AS try_count
+                    FROM
+                        user_exam uer
+                    WHERE
+                        uer.user_id = #{user.id}
+                    GROUP BY
+                        exam_id
+                ) tmp2
+                ON tmp1.ID = tmp2.exam_id
+                LEFT JOIN user_exam_result u on u.exam_id = tmp2.exam_id and u.user_id = #{user.id}
+            </when>
+        </choose>
         <where>
             <if test="exam.title!=null and exam.title!=''">
                 AND tmp1.title like concat('%', #{exam.title}, '%')