<?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.course.mapper.CourseMenuExamMapper">

    <resultMap type="com.zhongzheng.modules.course.domain.CourseMenuExam" id="CourseMenuExamResult">
        <result property="id" column="id"/>
        <result property="courseId" column="course_id"/>
        <result property="moduleId" column="module_id"/>
        <result property="chapterId" column="chapter_id"/>
        <result property="sectionId" column="section_id"/>
        <result property="type" column="type"/>
        <result property="examId" column="exam_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <resultMap type="com.zhongzheng.modules.course.vo.CourseMenuExamVo" id="CourseMenuExamVoResult">
        <result property="id" column="id"/>
        <result property="courseId" column="course_id"/>
        <result property="moduleId" column="module_id"/>
        <result property="chapterId" column="chapter_id"/>
        <result property="sectionId" column="section_id"/>
        <result property="type" column="type"/>
        <result property="examId" column="exam_id"/>
        <result property="examName" column="exam_name"/>
        <result property="doType" column="do_type"/>
    </resultMap>

    <select id="getList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuExamQueryBo" resultMap="CourseMenuExamVoResult">
        SELECT
            cme.*,
            e.exam_name,
            e.do_type
        FROM
            course_menu_exam cme
                LEFT JOIN exam e ON cme.exam_id = e.exam_id
        where cme.course_id = #{courseId}
        <if test="chapterId != null and chapterId != ''">
            AND cme.chapter_id = #{chapterId}
        </if>
        <if test="moduleId != null and moduleId != ''">
            AND cme.module_id = #{moduleId}
        </if>
    </select>

</mapper>
