|
@@ -72,39 +72,60 @@
|
|
|
|
|
|
<select id="selectExamList" resultType="com.ynfy.buss.exam.exam.entity.Exam">
|
|
|
SELECT
|
|
|
- tmp.*
|
|
|
+ tmp1.*
|
|
|
FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- *
|
|
|
- FROM exam
|
|
|
- WHERE
|
|
|
- open_type = 1
|
|
|
- <choose>
|
|
|
- <when test="user.orgCode!=null and user.orgCode!=''">
|
|
|
- UNION
|
|
|
- SELECT
|
|
|
- *
|
|
|
- FROM exam
|
|
|
- WHERE
|
|
|
- open_type = 2
|
|
|
- AND examiner like concat('%', #{user.orgCode}, '%')
|
|
|
- </when>
|
|
|
- </choose>
|
|
|
- UNION
|
|
|
- SELECT
|
|
|
- *
|
|
|
- FROM exam
|
|
|
- WHERE
|
|
|
- open_type = 3
|
|
|
- AND examiner like concat('%', #{user.username}, '%')
|
|
|
- ) tmp
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ *
|
|
|
+ FROM exam
|
|
|
+ WHERE
|
|
|
+ open_type = 1
|
|
|
+ <choose>
|
|
|
+ <when test="user.orgCode!=null and user.orgCode!=''">
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ *
|
|
|
+ FROM exam
|
|
|
+ WHERE
|
|
|
+ open_type = 2
|
|
|
+ AND examiner like concat('%', #{user.orgCode}, '%')
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ *
|
|
|
+ FROM exam
|
|
|
+ WHERE
|
|
|
+ open_type = 3
|
|
|
+ AND examiner like concat('%', #{user.username}, '%')
|
|
|
+ ) 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
|
|
|
<where>
|
|
|
+ (
|
|
|
+ CASE WHEN
|
|
|
+ tmp1.limit_count IS NOT NULL AND tmp2.try_count IS NOT NULL
|
|
|
+ THEN
|
|
|
+ tmp2.try_count < tmp1.limit_count
|
|
|
+ ELSE
|
|
|
+ 1 = 1
|
|
|
+ END
|
|
|
+ )
|
|
|
<if test="exam.title!=null and exam.title!=''">
|
|
|
- AND tmp.title like concat('%', #{exam.title}, '%')
|
|
|
+ AND tmp1.title like concat('%', #{exam.title}, '%')
|
|
|
</if>
|
|
|
<if test="exam.openType!=null">
|
|
|
- AND tmp.open_type = #{exam.openType}
|
|
|
+ AND tmp1.open_type = #{exam.openType}
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|