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

    <resultMap type="FsCourseFinishTemp" id="FsCourseFinishTempResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="status"    column="status"    />
        <result property="setting"    column="setting"    />
        <result property="companyId"    column="company_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="courseId"    column="course_id"    />
        <result property="videoId"    column="video_id"    />
        <result property="companyUserIds"    column="company_user_ids"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="chatSetting"    column="chat_setting"    />
        <result property="isAllCompanyUser"    column="is_all_company_user"    />
    </resultMap>

    <sql id="selectFsCourseFinishTempVo">
        select * from fs_course_finish_temp
    </sql>

    <select id="selectFsCourseFinishTempList" parameterType="FsCourseFinishTemp" resultType="FsCourseFinishTemp">
        <include refid="selectFsCourseFinishTempVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="setting != null  and setting != ''"> and setting = #{setting}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="courseId != null "> and course_id = #{courseId}</if>
            <if test="videoId != null "> and video_id = #{videoId}</if>
            <if test="companyUserIds != null  and companyUserIds != ''"> and company_user_ids = #{companyUserIds}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="isAllCompanyUser != null "> and is_all_company_user = #{isAllCompanyUser}</if>
        </where>
    </select>

    <select id="selectFsCourseFinishTempById" parameterType="Long" resultType="FsCourseFinishTemp">
        <include refid="selectFsCourseFinishTempVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsCourseFinishTemp" parameterType="FsCourseFinishTemp" useGeneratedKeys="true" keyProperty="id">
        insert into fs_course_finish_temp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="status != null">status,</if>
            <if test="setting != null">setting,</if>
            <if test="companyId != null">company_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="courseId != null">course_id,</if>
            <if test="videoId != null">video_id,</if>
            <if test="companyUserIds != null">company_user_ids,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="isAllCompanyUser != null">is_all_company_user,</if>
            <if test="chatSetting != null">chat_setting,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="status != null">#{status},</if>
            <if test="setting != null">#{setting},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="courseId != null">#{courseId},</if>
            <if test="videoId != null">#{videoId},</if>
            <if test="companyUserIds != null">#{companyUserIds},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="isAllCompanyUser != null">#{isAllCompanyUser},</if>
            <if test="chatSetting != null">#{chatSetting},</if>
        </trim>
    </insert>

    <update id="updateFsCourseFinishTemp" parameterType="FsCourseFinishTemp">
        update fs_course_finish_temp
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="status != null">status = #{status},</if>
            <if test="setting != null">setting = #{setting},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="courseId != null">course_id = #{courseId},</if>
            <if test="videoId != null">video_id = #{videoId},</if>
            <if test="companyUserIds != null">company_user_ids = #{companyUserIds},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="isAllCompanyUser != null">is_all_company_user = #{isAllCompanyUser},</if>
            <if test="chatSetting != null">chat_setting = #{chatSetting},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsCourseFinishTempById" parameterType="Long">
        delete from fs_course_finish_temp where id = #{id}
    </delete>

    <delete id="deleteFsCourseFinishTempByIds" parameterType="String">
        update fs_course_finish_temp set is_del = 1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
