<?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.exam.reserve.dao.TimePeriodExamRoomDao">

    <select id="listExamRoom" resultType="com.qmth.exam.reserve.entity.ExamRoomEntity">
        SELECT
            er.*
        FROM
            t_time_period_exam_room tper,
            t_exam_site es,
            t_exam_room er
        WHERE
            tper.exam_room_id = er.id
          AND er.exam_site_id = es.id
          AND tper.ENABLE = #{enable}
          AND tper.time_period_id = #{timePeriodId}
          AND es.id = #{examSiteId}
    </select>

    <select id="listByExamRoomIdsAndTimePeriodIds" resultType="com.qmth.exam.reserve.entity.TimePeriodExamRoomEntity">
        SELECT *
        FROM t_time_period_exam_room
        WHERE exam_room_id IN
        <foreach collection="examRoomIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        AND time_period_id IN
        <foreach collection="timePeriodIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <select id="listByExamRoomIdsAndTimePeriodId" resultType="com.qmth.exam.reserve.entity.TimePeriodExamRoomEntity">
        SELECT *
        FROM t_time_period_exam_room
        WHERE exam_room_id IN
        <foreach collection="examRoomIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        AND time_period_id = #{timePeriodId}
    </select>

</mapper>
