<?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.CourseMapper">

    <select id="getGradeMajorActivityCandidateCourse" resultType="rd.data.db.table.Course">
        select c.id,
               c.name,
               c.course_hours,
               c.create_time,
               c.edit_time,
               c.deleted,
               c.spring_term
        from course c inner join activity_target "at" on c.id = "at".course
        where "at".grade = #{grade} and "at".activity = #{activity} and "at".major = #{major}
          and "at".deleted = false and c.deleted = false
    </select>

    <select id="getStudentActivityCandidateCourse" resultType="rd.data.db.table.Course">
        select c.id,
               c.name,
               c.course_hours,
               c.create_time,
               c.edit_time,
               c.deleted,
               c.spring_term
        from course c
                 inner join activity_target "at" on c.id = "at".course
                 inner join student_info si on si.id = #{studentId}
        where "at".grade = si.grade
          and "at".major = si.major
          and "at".activity = #{activity}
          and "at".deleted = false
          and c.deleted = false
    </select>

</mapper>
