<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.ycl.jxkg.mapper.ExamMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.vo.ExamVO">
|
<result column="exam_name" property="examName" />
|
<result column="exam_paper_id" property="examPaperId" />
|
<result column="classes_id" property="classesId" />
|
<result column="exam_paper_type" property="examPaperType" />
|
<result column="exam_place" property="examPlace" />
|
<result column="status" property="status" />
|
<result column="start_time" property="startTime" />
|
<result column="end_time" property="endTime" />
|
<result column="create_time" property="createTime" />
|
<result column="teacher_id" property="teacherId" />
|
<result column="class_name" property="className" />
|
<result column="name" property="examPaperName" />
|
<result column="isContinue" property="isContinue" />
|
<result column="submitStatus" property="submitStatus" />
|
</resultMap>
|
|
<select id="getById" resultMap="BaseResultMap">
|
SELECT
|
TE.exam_name,
|
TE.exam_paper_id,
|
TE.classes_id,
|
TE.exam_paper_type,
|
TE.exam_place,
|
TE.status,
|
TE.start_time,
|
TE.end_time,
|
TE.create_time,
|
TE.teacher_id,
|
TE.id
|
FROM
|
t_exam TE
|
WHERE
|
TE.id = #{id} AND TE.deleted = 0
|
</select>
|
|
|
<select id="getPage" resultMap="BaseResultMap">
|
SELECT
|
TE.exam_name,
|
TE.exam_paper_id,
|
TE.classes_id,
|
TE.exam_paper_type,
|
TE.exam_place,
|
TE.status,
|
TE.start_time,
|
TE.end_time,
|
TE.create_time,
|
TE.teacher_id,
|
TE.id,
|
TC.class_name,
|
TEP.name
|
FROM
|
t_exam TE
|
INNER JOIN t_user TU ON TU.id = TE.teacher_id AND TU.deleted = 0 AND TU.id = #{userId}
|
LEFT JOIN t_classes TC ON TC.id = TE.classes_id AND TC.deleted = 0
|
LEFT JOIN t_exam_paper TEP ON TEP.id = TE.exam_paper_id AND TEP.deleted = 0
|
WHERE
|
TE.deleted = 0
|
<if test="query.examName != null and query.examName != ''">
|
AND TE.exam_name like concat('%', #{query.examName}, '%')
|
</if>
|
<if test="query.classesId != null">
|
AND TE.classes_id = #{query.classesId}
|
</if>
|
ORDER BY
|
TE.create_time DESC
|
</select>
|
|
|
<select id="studentPage" resultMap="BaseResultMap">
|
SELECT
|
TE.exam_name,
|
TE.exam_paper_id,
|
TE.classes_id,
|
TE.exam_paper_type,
|
TE.exam_place,
|
TE.status,
|
IF(TE.status != 'not_start', IF(TE.status = 'ing', 2, 1), 0) as orderc,
|
TE.start_time,
|
TE.end_time,
|
TE.create_time,
|
TE.teacher_id,
|
TE.id,
|
TC.class_name,
|
TEP.name,
|
TEST.status as submitStatus,
|
(SELECT IF(COUNT(*) > 0, true, false) FROM t_exam_submit_temp WHERE user_id = #{userId} AND status = 'temp') as isContinue
|
FROM
|
t_exam TE
|
INNER JOIN t_classes TC ON TC.id = TE.classes_id AND TC.deleted = 0 AND TC.status = 'normal'
|
INNER JOIN t_classes_user TCU ON TC.id = TCU.classes_id And TCU.deleted = 0 AND TC.deleted = 0 AND TCU.user_id = #{userId}
|
INNER JOIN t_exam_paper TEP ON TEP.id = TE.exam_paper_id AND TEP.deleted = 0
|
LEFT JOIN t_exam_submit_temp TEST ON TEST.exam_id = TE.id
|
WHERE
|
TE.deleted = 0 and (TEST.deleted =0 or TEST.deleted is null)
|
<if test="query.examName != null and query.examName != ''">
|
AND TE.exam_name like concat('%', #{query.examName}, '%')
|
</if>
|
<if test="query.status != null and query.status != ''">
|
AND TE.status = #{query.status}
|
</if>
|
ORDER BY FIELD(TE.status, 'ing', 'not_start', 'finished'), orderc, TE.create_time DESC
|
</select>
|
|
</mapper>
|