<?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.xjrsoft.module.room.mapper.RoomStudentAppointMapper">
    <select id="getPage" parameterType="com.xjrsoft.module.room.dto.RoomStudentAppointPageDto" resultType="com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo">
        select
        t.id as roomId,
        t4.name as genderCn,
        t.room_name as roomName,
        t.is_max as isMax
        from room t
        left join room_bed t1 on t1.room_id = t.id
        left join base_student_school_roll t2 on t2.user_id = t1.student_user_id
        left join base_class t3 on t3.id = t2.class_id
        left join xjr_dictionary_detail t4 on t4.code = t.gender
        where t.delete_mark = 0
        and t1.delete_mark = 0
        and t2.delete_mark = 0
        and t3.teacher_id = #{dto.teacherId}
        <if test="dto.gender != null and dto.gender != ''">
            and t.gender = #{dto.gender}
        </if>
        <if test="dto.roomId != null and dto.roomId > 0">
            and t.id = #{dto.roomId}
        </if>
        group by t.id,t4.name
    </select>
</mapper>