<?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.yonge.cooleshow.biz.dal.dao.PianoRoomTimeDao">
    <select id="selectRemainTime" resultType="com.yonge.cooleshow.biz.dal.vo.PianoRoomTimeVo"
            parameterType="java.lang.Long">
        SELECT *,
        (SELECT COUNT(1) FROM user_binding_teacher WHERE teacher_id_=#{teacherId}) AS studentCount
        FROM piano_room_time
        WHERE teacher_id_=#{teacherId}
    </select>
    <select id="countStudent" resultType="java.lang.Integer">
        SELECT COUNT(1) FROM user_binding_teacher WHERE teacher_id_=#{teacherId}
    </select>
    <update id="updateEndTime">
        <foreach collection="list" item="item" index="index" separator=";">
            UPDATE user_binding_teacher
            SET last_end_class_ = #{item.endTime}
            WHERE teacher_id_ = #{item.teacherId}
            AND student_id_ = #{item.studentId}
        </foreach>
    </update>
    <update id="updateBatch">
        <foreach collection="list" item="item" index="index" separator=";">
            UPDATE piano_room_time
            SET frozen_time_ = #{item.frozenTime}
            WHERE teacher_id_ = #{item.teacherId}
        </foreach>
    </update>
</mapper>
