<?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.zhongzheng.modules.goods.mapper.GoodsCourseMapper">

    <resultMap type="com.zhongzheng.modules.goods.domain.GoodsCourse" id="GoodsCourseResult">
        <result property="id" column="id"/>
        <result property="goodsId" column="goods_id"/>
        <result property="courseId" column="course_id"/>
        <result property="sort" column="sort"/>
    </resultMap>

    <resultMap type="com.zhongzheng.modules.course.vo.CourseVo" id="CourseResultVo">
        <result property="courseId" column="course_id"/>
        <result property="prefixName" column="prefix_name"/>
        <result property="coverUrl" column="cover_url"/>
        <result property="introduction" column="introduction"/>
        <result property="status" column="status"/>
        <result property="educationTypeId" column="education_type_id"/>
        <result property="businessId" column="business_id"/>
        <result property="schoolId" column="school_id"/>
        <result property="courseName" column="course_name"/>
        <result property="publishStatus" column="publish_status"/>
        <result property="sort" column="sort"/>
        <result property="suitableObject" column="suitable_object"/>
        <result property="pcDetailHtml" column="pc_detail_html"/>
        <result property="mobileDetailHtml" column="mobile_detail_html"/>
        <result property="majorId" column="major_id"/>
        <result property="code" column="code"/>
        <result property="subjectId" column="subject_id"/>
        <result property="projectId" column="project_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="educationName" column="education_name"/>
        <result property="projectName" column="project_name"/>
        <result property="businessName" column="business_name"/>
        <result property="schoolName" column="school_name"/>
        <result property="categoryName" column="category_name"/>
        <result property="subjectName" column="subject_name"/>
        <result property="sort" column="g_sort"/>
    </resultMap>




    <select id="selectList" parameterType="Long" resultMap="CourseResultVo">
        SELECT
        c.*,
        cet.education_name,
        cpt.project_name,
        cb.business_name,
        s.school_name,
        m.category_name,
        cs.subject_name,
               gc.sort as g_sort
        FROM
        goods_course gc
        LEFT JOIN course c ON gc.course_id = c.course_id
        LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
        LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
        LEFT JOIN course_business cb ON c.business_id = cb.id
        LEFT JOIN school s ON s.id = c.school_id
        LEFT JOIN major m ON c.major_id = m.id
        LEFT JOIN course_subject cs ON cs.id = c.subject_id
        WHERE
        gc.goods_id = #{goodsId} AND c.`status` = 1
    </select>
</mapper>
