<?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.live.mapper.LiveWatchConfigMapper">

    <resultMap type="LiveWatchConfig" id="LiveWatchConfigResult">
        <result property="id"    column="id"    />
        <result property="liveId"    column="live_id"    />
        <result property="participateCondition"    column="participate_condition"    />
        <result property="watchDuration"    column="watch_duration"    />
        <result property="action"    column="action"    />
        <result property="receivePrompt"    column="receive_prompt"    />
        <result property="redPacketType"    column="red_packet_type"    />
        <result property="redPacketAmount"    column="red_packet_amount"    />
        <result property="redPacketRandomAmount"    column="red_packet_random_amount"    />
        <result property="redPacketCount"    column="red_packet_count"    />
        <result property="redPacketReceiveMethod"    column="red_packet_receive_method"    />
        <result property="redPacketReceiveTimeLimit"    column="red_packet_receive_time_limit"    />
        <result property="redPacketWithdrawCondition"    column="red_packet_withdraw_condition"    />
        <result property="redPacketGuide"    column="red_packet_guide"    />
        <result property="redPacketGuideText"    column="red_packet_guide_text"    />
        <result property="scoreAmount"    column="score_amount"    />
        <result property="scoreMaxReceiver"    column="score_max_receiver"    />
        <result property="scoreGuide"    column="score_guide"    />
        <result property="scoreGuideLink"    column="score_guide_link"    />
        <result property="scoreGuideText"    column="score_guide_text"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="configJson"    column="config_json"    />
    </resultMap>

    <sql id="selectLiveWatchConfigVo">
        select id, live_id, participate_condition, watch_duration, action, receive_prompt, red_packet_type, red_packet_amount, red_packet_random_amount, red_packet_count, red_packet_receive_method, red_packet_receive_time_limit, red_packet_withdraw_condition, red_packet_guide, red_packet_guide_text, score_amount, score_max_receiver, score_guide, score_guide_link, score_guide_text, create_time, create_by, update_time, update_by, configJson from live_watch_config
    </sql>

    <select id="selectLiveWatchConfigList" parameterType="LiveWatchConfig" resultMap="LiveWatchConfigResult">
        <include refid="selectLiveWatchConfigVo"/>
        <where>
            <if test="liveId != null "> and live_id = #{liveId}</if>
            <if test="participateCondition != null "> and participate_condition = #{participateCondition}</if>
            <if test="watchDuration != null "> and watch_duration = #{watchDuration}</if>
            <if test="action != null "> and action = #{action}</if>
            <if test="receivePrompt != null  and receivePrompt != ''"> and receive_prompt = #{receivePrompt}</if>
            <if test="redPacketType != null "> and red_packet_type = #{redPacketType}</if>
            <if test="redPacketAmount != null "> and red_packet_amount = #{redPacketAmount}</if>
            <if test="redPacketRandomAmount != null  and redPacketRandomAmount != ''"> and red_packet_random_amount = #{redPacketRandomAmount}</if>
            <if test="redPacketCount != null "> and red_packet_count = #{redPacketCount}</if>
            <if test="redPacketReceiveMethod != null "> and red_packet_receive_method = #{redPacketReceiveMethod}</if>
            <if test="redPacketReceiveTimeLimit != null "> and red_packet_receive_time_limit = #{redPacketReceiveTimeLimit}</if>
            <if test="redPacketWithdrawCondition != null "> and red_packet_withdraw_condition = #{redPacketWithdrawCondition}</if>
            <if test="redPacketGuide != null "> and red_packet_guide = #{redPacketGuide}</if>
            <if test="redPacketGuideText != null  and redPacketGuideText != ''"> and red_packet_guide_text = #{redPacketGuideText}</if>
            <if test="scoreAmount != null "> and score_amount = #{scoreAmount}</if>
            <if test="scoreMaxReceiver != null "> and score_max_receiver = #{scoreMaxReceiver}</if>
            <if test="scoreGuide != null "> and score_guide = #{scoreGuide}</if>
            <if test="scoreGuideLink != null  and scoreGuideLink != ''"> and score_guide_link = #{scoreGuideLink}</if>
            <if test="scoreGuideText != null  and scoreGuideText != ''"> and score_guide_text = #{scoreGuideText}</if>
            <if test="configJson != null  and configJson != ''"> and config_json = #{configJson}</if>
        </where>
    </select>

    <select id="selectLiveWatchConfigById" parameterType="Long" resultMap="LiveWatchConfigResult">
        <include refid="selectLiveWatchConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertLiveWatchConfig" parameterType="LiveWatchConfig" useGeneratedKeys="true" keyProperty="id">
        insert into live_watch_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="liveId != null">live_id,</if>
            <if test="participateCondition != null">participate_condition,</if>
            <if test="watchDuration != null">watch_duration,</if>
            <if test="action != null">action,</if>
            <if test="receivePrompt != null and receivePrompt != ''">receive_prompt,</if>
            <if test="redPacketType != null">red_packet_type,</if>
            <if test="redPacketAmount != null">red_packet_amount,</if>
            <if test="redPacketRandomAmount != null">red_packet_random_amount,</if>
            <if test="redPacketCount != null">red_packet_count,</if>
            <if test="redPacketReceiveMethod != null">red_packet_receive_method,</if>
            <if test="redPacketReceiveTimeLimit != null">red_packet_receive_time_limit,</if>
            <if test="redPacketWithdrawCondition != null">red_packet_withdraw_condition,</if>
            <if test="redPacketGuide != null">red_packet_guide,</if>
            <if test="redPacketGuideText != null">red_packet_guide_text,</if>
            <if test="scoreAmount != null">score_amount,</if>
            <if test="scoreMaxReceiver != null">score_max_receiver,</if>
            <if test="scoreGuide != null">score_guide,</if>
            <if test="scoreGuideLink != null">score_guide_link,</if>
            <if test="scoreGuideText != null">score_guide_text,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="configJson != null">config_json,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="liveId != null">#{liveId},</if>
            <if test="participateCondition != null">#{participateCondition},</if>
            <if test="watchDuration != null">#{watchDuration},</if>
            <if test="action != null">#{action},</if>
            <if test="receivePrompt != null and receivePrompt != ''">#{receivePrompt},</if>
            <if test="redPacketType != null">#{redPacketType},</if>
            <if test="redPacketAmount != null">#{redPacketAmount},</if>
            <if test="redPacketRandomAmount != null">#{redPacketRandomAmount},</if>
            <if test="redPacketCount != null">#{redPacketCount},</if>
            <if test="redPacketReceiveMethod != null">#{redPacketReceiveMethod},</if>
            <if test="redPacketReceiveTimeLimit != null">#{redPacketReceiveTimeLimit},</if>
            <if test="redPacketWithdrawCondition != null">#{redPacketWithdrawCondition},</if>
            <if test="redPacketGuide != null">#{redPacketGuide},</if>
            <if test="redPacketGuideText != null">#{redPacketGuideText},</if>
            <if test="scoreAmount != null">#{scoreAmount},</if>
            <if test="scoreMaxReceiver != null">#{scoreMaxReceiver},</if>
            <if test="scoreGuide != null">#{scoreGuide},</if>
            <if test="scoreGuideLink != null">#{scoreGuideLink},</if>
            <if test="scoreGuideText != null">#{scoreGuideText},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="configJson != null">#{configJson},</if>
         </trim>
    </insert>

    <update id="updateLiveWatchConfig" parameterType="LiveWatchConfig">
        update live_watch_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="liveId != null">live_id = #{liveId},</if>
            <if test="participateCondition != null">participate_condition = #{participateCondition},</if>
            <if test="watchDuration != null">watch_duration = #{watchDuration},</if>
            <if test="action != null">action = #{action},</if>
            <if test="receivePrompt != null and receivePrompt != ''">receive_prompt = #{receivePrompt},</if>
            <if test="redPacketType != null">red_packet_type = #{redPacketType},</if>
            <if test="redPacketAmount != null">red_packet_amount = #{redPacketAmount},</if>
            <if test="redPacketRandomAmount != null">red_packet_random_amount = #{redPacketRandomAmount},</if>
            <if test="redPacketCount != null">red_packet_count = #{redPacketCount},</if>
            <if test="redPacketReceiveMethod != null">red_packet_receive_method = #{redPacketReceiveMethod},</if>
            <if test="redPacketReceiveTimeLimit != null">red_packet_receive_time_limit = #{redPacketReceiveTimeLimit},</if>
            <if test="redPacketWithdrawCondition != null">red_packet_withdraw_condition = #{redPacketWithdrawCondition},</if>
            <if test="redPacketGuide != null">red_packet_guide = #{redPacketGuide},</if>
            <if test="redPacketGuideText != null">red_packet_guide_text = #{redPacketGuideText},</if>
            <if test="scoreAmount != null">score_amount = #{scoreAmount},</if>
            <if test="scoreMaxReceiver != null">score_max_receiver = #{scoreMaxReceiver},</if>
            <if test="scoreGuide != null">score_guide = #{scoreGuide},</if>
            <if test="scoreGuideLink != null">score_guide_link = #{scoreGuideLink},</if>
            <if test="scoreGuideText != null">score_guide_text = #{scoreGuideText},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="configJson != null">config_json = #{configJson},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLiveWatchConfigById" parameterType="Long">
        delete from live_watch_config where id = #{id}
    </delete>

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