<?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.ExamRoomDao">
    <select id="pageExamRoom" resultType="com.qmth.exam.reserve.bean.room.ExamRoomVO">
        SELECT
            r.ID,
            r.CODE,
            r.NAME,
            r.address,
            r.capacity,
            s.NAME examSiteName,
            s.ID examsiteid,
            g.NAME teachingName,
            g.ID teachingId,
            r.ENABLE
        FROM
            t_exam_room r,
            t_exam_site s,
            t_category g
        WHERE
            r.exam_site_id = s.id
          AND s.category_id = g.id
        <if test="req.teachingId != null">
            AND s.category_id=#{req.teachingId}
        </if>
        <if test="req.examSiteId != null">
            AND s.id=#{req.examSiteId}
        </if>
        <if test="req.enable != null">
            AND r.enable=#{req.enable}
        </if>
        <if test="req.name != null and req.name != ''">
            AND r.name like concat('%',#{req.name}, '%')
        </if>
        order by r.update_time desc
    </select>
</mapper>
