<?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.qmth.teachcloud.common.mapper.BasicUserCourseMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.teachcloud.common.entity.BasicUserCourse">
    <result column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="course_id" property="courseId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        user_id, course_id
    </sql>
    <select id="listBySchoolIdAndCourseCode" resultType="com.qmth.teachcloud.common.entity.BasicUserCourse">
        SELECT
            a.id,
            a.school_id schoolId,
            a.org_id orgId,
            a.user_id userId,
            a.course_id courseId,
            a.clazz_id clazzId,
            a.create_id createId,
            a.create_time createTime
        FROM
            basic_user_course a
                LEFT JOIN
            basic_course b ON a.course_id = b.id
        WHERE
            a.school_id = #{schoolId} AND b.code = #{courseCode}
    </select>

</mapper>
