<?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="rd.dao.mapper.course.CourseTeacherMapper">

    <select id="getAllCourseScheduleForTeacher" resultType="rd.data.db.CourseScheduleWithCourseIdName">
        SELECT csch.id  as scheduleId,
               csch.start_week,
               csch.end_week,
               csch.time,
               csch.academic_term,
               csch.place,
               csch.weekday,
               crs.id   as courseId,
               crs.name as courseName,
               crs.exam_ratio,
               crs.course_hours,
               crs.spring_term
        FROM course_schedule csch
                 INNER JOIN course_teacher ct ON ct.course = csch.course and csch.academic_term = #{term}
            AND ct.teacher = #{teacher}
                 INNER JOIN course crs ON crs.id = csch.course;
    </select>

    <select id="getCourseAllTeacherInfo" resultType="rd.data.db.table.TeacherInfo">
        select teacher_info.*
        from course_teacher
                 inner join teacher_info on teacher_info."id" = course_teacher.teacher
        where course_teacher.course = #{course}
    </select>
    <select id="getCourseForTeacher" resultType="rd.data.db.table.Course">
        select *
        from course crs
        where crs.id in (select course
                         from course_teacher tc
                         where tc.teacher = #{teacher})
    </select>
</mapper>
