<?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.qmth.themis.business.dao.TEExamBreachLogMapper">
	<select id="getExamBreachPage"
		resultType="com.qmth.themis.business.bean.backend.ExamBreachListBean">
		SELECT
		f.exam_student_id examStudentId,
		t.exam_id examId,
		t.exam_activity_id examActivityId,
		t.room_code roomCode,
		t.course_code
		courseCode,
		t.course_name courseName,
		t.NAME,
		t.identity,
		t.room_name
		roomName,'违纪' breachStatus
		FROM
		t_e_exam_breach_log f
		LEFT JOIN
		t_e_exam_student t ON f.exam_student_id = t.id
		where f.exam_id
		=#{examId} and f.status=0
		<if test="activityId != null and activityId != ''">
			and f.exam_activity_id = #{activityId}
		</if>
		<if test="roomCode != null and roomCode != ''">
			and t.room_code =#{roomCode}
		</if>
		<if test="courseCode != null and courseCode != ''">
			and t.course_code = #{courseCode}
		</if>
		<if test="identity != null and identity != ''">
			and t.identity like concat(#{identity},'%')
		</if>
		<if test="name != null and name != ''">
			and t.name like concat(#{name},'%')
		</if>
	</select>
	<select id="getExamRevokeBreachPage"
		resultType="com.qmth.themis.business.bean.backend.ExamBreachListBean">
		SELECT
		f.exam_student_id examStudentId,
		t.exam_id examId,
		t.exam_activity_id examActivityId,
		t.room_code roomCode,
		t.course_code
		courseCode,
		t.course_name courseName,
		t.NAME,
		t.identity,
		t.room_name
		roomName,'正常' breachStatus
		FROM
		t_e_exam_breach_log f
		LEFT JOIN
		t_e_exam_student t ON f.exam_student_id = t.id
		where f.exam_id
		=#{examId} and f.status=1
		<if test="activityId != null and activityId != ''">
			and f.exam_activity_id = #{activityId}
		</if>
		<if test="roomCode != null and roomCode != ''">
			and t.room_code =#{roomCode}
		</if>
		<if test="courseCode != null and courseCode != ''">
			and t.course_code = #{courseCode}
		</if>
		<if test="identity != null and identity != ''">
			and t.identity like concat(#{identity},'%')
		</if>
		<if test="name != null and name != ''">
			and t.name like concat(#{name},'%')
		</if>
	</select>

	<select id="getExamBreachDetailList"
		resultType="com.qmth.themis.business.bean.backend.ExamBreachDetailListBean">
		SELECT
		(case when f.status=0 then '违纪处理' else '撤销违纪'
		end)status,
		t.name createName,
		f.update_time
		endTime,
		f.type type,
		f.remark remark
		FROM
		t_e_exam_breach_log f
		left join
		t_b_user t on f.create_id=t.id
		where f.exam_student_id
		=#{examStudentId}
		order by f.create_time
	</select>
</mapper>
