<?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.store.mapper.FsStoreCouponIssueUserMapper">
    
    <resultMap type="FsStoreCouponIssueUser" id="FsStoreCouponIssueUserResult">
        <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"    />
    </resultMap>

    <sql id="selectFsStoreCouponIssueUserVo">
        select id, user_id, issue_id, create_time, update_time, is_del from fs_store_coupon_issue_user
    </sql>

    <select id="selectFsStoreCouponIssueUserList" parameterType="FsStoreCouponIssueUser" resultMap="FsStoreCouponIssueUserResult">
        <include refid="selectFsStoreCouponIssueUserVo"/>
        <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>
        </where>
    </select>
    
    <select id="selectFsStoreCouponIssueUserById" parameterType="Long" resultMap="FsStoreCouponIssueUserResult">
        <include refid="selectFsStoreCouponIssueUserVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreCouponIssueUser" parameterType="FsStoreCouponIssueUser" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_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>
         </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>
         </trim>
    </insert>

    <update id="updateFsStoreCouponIssueUser" parameterType="FsStoreCouponIssueUser">
        update fs_store_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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreCouponIssueUserById" parameterType="Long">
        delete from fs_store_coupon_issue_user where id = #{id}
    </delete>

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