<?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.jkserver.dao.ExamStudentTempDao">

    <select id="findByExamCodeAndAttachmentId" resultType="com.qmth.jkserver.model.ExamStudentTemp">
        select * from jk_exam_student_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="attachmentId != null and attachmentId != ''">
                and t.attachment_id = #{attachmentId}
            </if>
        </where>
    </select>

    <select id="findByExamCodeAndAttachmentIdByMap" resultType="java.util.Map">
        select t.course_code as courseCode,t.course_name as courseName from jk_exam_student_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="attachmentId != null and attachmentId != ''">
                and t.attachment_id = #{attachmentId}
            </if>
        </where>
        group by t.course_code,t.course_name
        order by t.course_code
    </select>

    <select id="findByExamCodeByMap" resultType="java.util.Map">
        select t.exam_code as examCode,t.place_code as placeCode from jk_exam_student_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
        group by t.exam_code,t.place_code
        order by t.place_code
    </select>

    <select id="findByExamCodeAndPlaceCodeByMap" resultType="java.util.Map">
        select t.room_code as roomCode from jk_exam_student_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="placeCode != null and placeCode != ''">
                and t.place_code = #{placeCode}
            </if>
        </where>
        group by t.place_code,t.room_code
        order by t.room_code
    </select>


    <select id="findByExamCode" resultType="com.qmth.jkserver.model.ExamStudentTemp">
        select * from jk_exam_student_temp t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="attachmentId != null and attachmentId != ''">
                and t.attachment_id = #{attachmentId}
            </if>
            <if test="batchId != null and batchId != ''">
                and t.batch_id = #{batchId}
            </if>
            <if test="stageId != null and stageId != ''">
                and t.stage_id = #{stageId}
            </if>
            <if test="placeCode != null and placeCode != ''">
                and t.place_code = #{placeCode}
            </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="querykey != null and querykey != ''">
                and (t.name like concat('%', #{querykey}, '%') or t.ticket_no like concat('%', #{querykey}, '%'))
            </if>
        </where>
    </select>
</mapper>
