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

    <resultMap type="com.zhongzheng.modules.course.domain.CourseSection" id="CourseSectionResult">
        <result property="sectionId" column="section_id"/>
        <result property="chapterId" column="chapter_id"/>
        <result property="name" column="name"/>
        <result property="videoUrl" column="video_url"/>
        <result property="videoTime" column="video_time"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="status" column="status"/>
        <result property="sort" column="sort"/>
        <result property="polyvId" column="polyv_id"/>
        <result property="duration" column="duration"/>
        <result property="mp4" column="mp4"/>
        <result property="firstImage" column="first_image"/>
        <result property="vid" column="vid"/>
    </resultMap>

    <select id="selectCourseSectionList" parameterType="com.zhongzheng.modules.course.bo.CourseSectionQueryBo"  resultMap="CourseSectionResult">
        SELECT
        cs.section_id,
        cs.name,
        cs.chapter_id,
        cs.`status`,
        pv.duration,
        pv.first_image,
        pv.mp4,
        pv.vid
        FROM
        course_section cs
        LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
        WHERE 1=1
        <if test="status != null and status.size()!=0 ">
            AND cs.status in
            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="name != null and name != ''">
            AND cs.name like concat('%', #{bankName}, '%')
        </if>
        <if test="chapterId != null and chapterId != ''">
            AND cs.chapter_id = #{chapterId}
        </if>
    </select>
</mapper>
