<?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.ExamRoomTempDao">

    <select id="findByExamCodeAndAttachmentId" resultType="com.qmth.jkserver.model.ExamRoomTemp">
        select * from jk_exam_room_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.place_code as placeCode,t.place_name as placeName from jk_exam_room_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.place_code,t.place_name
        order by t.place_code
    </select>

    <select id="findByExamCodeAndAttachmentIdGroupByRoomCodeByMap" resultType="java.util.Map">
        select t.room_code as roomCode,t.room_name as roomName from jk_exam_room_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.room_code,t.room_name
        order by t.room_code
    </select>

    <select id="findByExamCode" resultType="com.qmth.jkserver.model.ExamRoomTemp">
        select * from jk_exam_room_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="placeCode != null and placeCode != ''">
                and t.place_code = #{placeCode}
            </if>
        </where>
    </select>
</mapper>
