<?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.ym.mec.education.mapper.TeacherAttendanceMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ym.mec.education.entity.TeacherAttendance">
        <id column="id_" property="id"/>
        <result column="teacher_id_" property="teacherId"/>
        <result column="music_group_id_" property="musicGroupId"/>
        <result column="class_group_id_" property="classGroupId"/>
        <result column="course_schedule_id_" property="courseScheduleId"/>
        <result column="sign_in_time_" property="signInTime"/>
        <result column="sign_out_time_" property="signOutTime"/>
        <result column="status_" property="status"/>
        <result column="remark_" property="remark"/>
        <result column="create_time_" property="createTime"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id_, teacher_id_, music_group_id_, class_group_id_, course_schedule_id_, sign_in_time_, sign_in_status_, remark_, create_time_,sign_out_time_
    </sql>
    <sql id="Column_List">
        teacher_attendance.id_, teacher_attendance.teacher_id_, teacher_attendance.music_group_id_,
        teacher_attendance.class_group_id_, teacher_attendance.course_schedule_id_,
        teacher_attendance.sign_in_time_, teacher_attendance.sign_in_status_,
        teacher_attendance.remark_, teacher_attendance.create_time_,teacher_attendance.sign_out_time_
    </sql>

    <!--上课记录-->
    <select id="selectClassRecordPage" parameterType="com.ym.mec.education.req.TeacherLeaveRecordReq"
            resultMap="BaseResultMap">
        select
        <include refid="Column_List"/>
        from teacher_attendance left join course_schedule
        on teacher_attendance.course_schedule_id_ = course_schedule.id_
        where
        teacher_attendance.teacher_id_ = #{query.teacherId}
        <if test="query.courseType != null and query.courseType != ''">
            and course_schedule.type_ = #{query.courseType}
        </if>
    </select>
</mapper>
