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

    <resultMap type="LiveLotteryRecord" id="LiveLotteryRecordResult">
        <result property="lotteryId"    column="lottery_id"    />
        <result property="liveId"    column="live_id"    />
        <result property="lotterystatus"    column="lottery_status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectLiveLotteryRecordVo">
        select lottery_id, live_id, lottery_status, create_time, update_time, create_by, update_by from live_lottery_record
    </sql>

    <select id="selectLiveLotteryRecordList" parameterType="LiveLotteryRecord" resultMap="LiveLotteryRecordResult">
        <include refid="selectLiveLotteryRecordVo"/>
        <where>
            <if test="liveId != null "> and live_id = #{liveId}</if>
            <if test="lotterystatus != null "> and lottery_status = #{lotterystatus}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
        </where>
    </select>

    <select id="selectLiveLotteryRecordByLotteryId" parameterType="Long" resultMap="LiveLotteryRecordResult">
        <include refid="selectLiveLotteryRecordVo"/>
        where lottery_id = #{lotteryId}
    </select>

    <insert id="insertLiveLotteryRecord" parameterType="LiveLotteryRecord" useGeneratedKeys="true" keyProperty="lotteryId">
        insert into live_lottery_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="liveId != null">live_id,</if>
            <if test="lotterystatus != null">lottery_status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="liveId != null">#{liveId},</if>
            <if test="lotterystatus != null">#{lotterystatus},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateLiveLotteryRecord" parameterType="LiveLotteryRecord">
        update live_lottery_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="liveId != null">live_id = #{liveId},</if>
            <if test="lotterystatus != null">lottery_status = #{lotterystatus},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where lottery_id = #{lotteryId}
    </update>

    <delete id="deleteLiveLotteryRecordByLotteryId" parameterType="Long">
        delete from live_lottery_record where lottery_id = #{lotteryId}
    </delete>

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