<?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.LiveRewardCompensationMapper">
    
    <resultMap type="LiveRewardCompensation" id="LiveRewardCompensationResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="unionId"    column="union_id"    />
        <result property="status"    column="status"    />
        <result property="logType"    column="log_type"    />
        <result property="businessId"    column="business_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="integral"    column="integral"    />
    </resultMap>

    <sql id="selectLiveRewardCompensationVo">
        select id, user_id, union_id, status, log_type, business_id, create_time, update_time,integral from live_reward_compensation
    </sql>

    <select id="selectLiveRewardCompensationList" parameterType="LiveRewardCompensation" resultMap="LiveRewardCompensationResult">
        <include refid="selectLiveRewardCompensationVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="unionId != null  and unionId != ''"> and union_id = #{unionId}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="logType != null "> and log_type = #{logType}</if>
            <if test="businessId != null "> and business_id = #{businessId}</if>
        </where>
    </select>
    
    <select id="selectLiveRewardCompensationById" parameterType="Long" resultMap="LiveRewardCompensationResult">
        <include refid="selectLiveRewardCompensationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertLiveRewardCompensation" parameterType="LiveRewardCompensation">
        insert into live_reward_compensation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="unionId != null">union_id,</if>
            <if test="status != null">status,</if>
            <if test="logType != null">log_type,</if>
            <if test="businessId != null">business_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="integral != null">integral,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="unionId != null">#{unionId},</if>
            <if test="status != null">#{status},</if>
            <if test="logType != null">#{logType},</if>
            <if test="businessId != null">#{businessId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="integral != null">#{integral},</if>
         </trim>
    </insert>

    <update id="updateLiveRewardCompensation" parameterType="LiveRewardCompensation">
        update live_reward_compensation
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="unionId != null">union_id = #{unionId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="logType != null">log_type = #{logType},</if>
            <if test="businessId != null">business_id = #{businessId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="integral != null">integral = #{integral},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLiveRewardCompensationById" parameterType="Long">
        delete from live_reward_compensation where id = #{id}
    </delete>

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