<?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.FsUserPromoterApplyMapper">
    
    <resultMap type="FsUserPromoterApply" id="FsUserPromoterApplyResult">
        <result property="applyId"    column="apply_id"    />
        <result property="userId"    column="user_id"    />
        <result property="contentJson"    column="content_json"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectFsUserPromoterApplyVo">
        select apply_id, user_id, content_json, create_time from fs_user_promoter_apply
    </sql>

    <select id="selectFsUserPromoterApplyList" parameterType="FsUserPromoterApply" resultMap="FsUserPromoterApplyResult">
        <include refid="selectFsUserPromoterApplyVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="contentJson != null  and contentJson != ''"> and content_json = #{contentJson}</if>
        </where>
    </select>
    
    <select id="selectFsUserPromoterApplyById" parameterType="Long" resultMap="FsUserPromoterApplyResult">
        <include refid="selectFsUserPromoterApplyVo"/>
        where apply_id = #{applyId}
    </select>
        
    <insert id="insertFsUserPromoterApply" parameterType="FsUserPromoterApply" useGeneratedKeys="true" keyProperty="applyId">
        insert into fs_user_promoter_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="contentJson != null">content_json,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="contentJson != null">#{contentJson},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateFsUserPromoterApply" parameterType="FsUserPromoterApply">
        update fs_user_promoter_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="contentJson != null">content_json = #{contentJson},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where apply_id = #{applyId}
    </update>

    <delete id="deleteFsUserPromoterApplyById" parameterType="Long">
        delete from fs_user_promoter_apply where apply_id = #{applyId}
    </delete>

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