<?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.TeacherAttendanceDao">
    <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.TeacherAttendance">
        <id column="id_" jdbcType="INTEGER" property="id"/>
        <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>
        <result column="course_group_type_" jdbcType="VARCHAR" property="courseGroupType"/>
        <result column="course_group_id_" jdbcType="INTEGER" property="courseGroupId"/>
        <result column="course_schedule_id_" jdbcType="INTEGER" property="courseScheduleId"/>
        <result column="sign_in_time_" jdbcType="TIMESTAMP" property="signInTime"/>
        <result column="sign_out_time_" jdbcType="TIMESTAMP" property="signOutTime"/>
        <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>

    <sql id="Base_Column_List">
        id_
        , teacher_id_, course_group_type_, course_group_id_, course_schedule_id_, sign_in_time_, sign_out_time_,
        create_time_, update_time_
    </sql>

    <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
            parameterType="com.yonge.cooleshow.biz.dal.entity.TeacherAttendance">
        insert into teacher_attendance(teacher_id_, course_group_type_, course_group_id_, course_schedule_id_,
        sign_in_time_, sign_out_time_, create_time_, update_time_)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.teacherId}, #{entity.courseGroupType}, #{entity.courseGroupId}, #{entity.courseScheduleId},
            #{entity.signInTime}, #{entity.signOutTime}, #{entity.createTime}, #{entity.updateTime})
        </foreach>
    </insert>
    <select id="findByUserIdAndCourseId" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from teacher_attendance where teacher_id_ = #{userId} and
        course_schedule_id_ = #{scheduleId} LIMIT 1
    </select>

</mapper>
