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

    <resultMap type="FsUserCourseVideoRedPackage" id="FsUserCourseVideoRedPackageResult">
        <result property="id"    column="id"    />
        <result property="companyId"    column="company_id"    />
        <result property="videoId"    column="video_id"    />
        <result property="redPacketMoney"    column="red_packet_money"    />
    </resultMap>

    <sql id="selectFsUserCourseVideoRedPackageVo">
        select id, company_id, video_id, red_packet_money from fs_user_course_video_red_package
    </sql>

    <select id="selectFsUserCourseVideoRedPackageList" parameterType="FsUserCourseVideoRedPackage" resultMap="FsUserCourseVideoRedPackageResult">
        <include refid="selectFsUserCourseVideoRedPackageVo"/>
        <where>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="videoId != null "> and video_id = #{videoId}</if>
            <if test="redPacketMoney != null "> and red_packet_money = #{redPacketMoney}</if>
        </where>
    </select>

    <select id="selectFsUserCourseVideoRedPackageById" parameterType="Long" resultMap="FsUserCourseVideoRedPackageResult">
        <include refid="selectFsUserCourseVideoRedPackageVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsUserCourseVideoRedPackage" parameterType="FsUserCourseVideoRedPackage" useGeneratedKeys="true" keyProperty="id">
        insert into fs_user_course_video_red_package
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyId != null">company_id,</if>
            <if test="videoId != null">video_id,</if>
            <if test="redPacketMoney != null">red_packet_money,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyId != null">#{companyId},</if>
            <if test="videoId != null">#{videoId},</if>
            <if test="redPacketMoney != null">#{redPacketMoney},</if>
         </trim>
    </insert>

    <update id="updateFsUserCourseVideoRedPackage" parameterType="FsUserCourseVideoRedPackage">
        update fs_user_course_video_red_package
        <trim prefix="SET" suffixOverrides=",">
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="videoId != null">video_id = #{videoId},</if>
            <if test="redPacketMoney != null">red_packet_money = #{redPacketMoney},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsUserCourseVideoRedPackageById" parameterType="Long">
        delete from fs_user_course_video_red_package where id = #{id}
    </delete>

    <delete id="deleteFsUserCourseVideoRedPackageByIds" parameterType="String">
        delete from fs_user_course_video_red_package where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
