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

    <resultMap type="LiveCouponIssueUser" id="LiveCouponIssueUserResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="issueId"    column="issue_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="liveId"    column="live_id"    />
    </resultMap>

    <sql id="selectLiveCouponIssueUserVo">
        select id, user_id, issue_id, create_time, update_time, is_del,goods_id,live_id from live_coupon_issue_user
    </sql>

    <select id="selectLiveCouponIssueUserList" parameterType="LiveCouponIssueUser" resultMap="LiveCouponIssueUserResult">
        <include refid="selectLiveCouponIssueUserVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="issueId != null "> and issue_id = #{issueId}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="goodsId != null "> and goods_id = #{goodsId}</if>
            <if test="liveId != null "> and live_id = #{liveId}</if>
        </where>
    </select>

    <select id="selectLiveCouponIssueUserById" parameterType="Long" resultMap="LiveCouponIssueUserResult">
        <include refid="selectLiveCouponIssueUserVo"/>
        where id = #{id}
    </select>

    <insert id="insertLiveCouponIssueUser" parameterType="LiveCouponIssueUser" useGeneratedKeys="true" keyProperty="id">
        insert into live_coupon_issue_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="issueId != null">issue_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="goodsId != null">goods_id,</if>
            <if test="liveId != null">live_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="issueId != null">#{issueId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="goodsId != null">#{goodsId},</if>
            <if test="liveId != null">#{liveId},</if>
         </trim>
    </insert>

    <update id="updateLiveCouponIssueUser" parameterType="LiveCouponIssueUser">
        update live_coupon_issue_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="issueId != null">issue_id = #{issueId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="liveId != null">live_id = #{liveId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLiveCouponIssueUserById" parameterType="Long">
        delete from live_coupon_issue_user where id = #{id}
    </delete>

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

</mapper>
