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

    <resultMap type="FsFollowTemp" id="FsFollowTempResult">
        <result property="tempId"    column="temp_id"    />
        <result property="name"    column="name"    />
        <result property="secondName"    column="second_name"    />
        <result property="formJson"    column="form_json"    />
        <result property="sort"    column="sort"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFsFollowTempVo">
        select temp_id, name, second_name, form_json, sort, status, create_by, create_time, update_by, update_time from fs_follow_temp
    </sql>

    <select id="selectFsFollowTempList" parameterType="FsFollowTemp" resultMap="FsFollowTempResult">
        <include refid="selectFsFollowTempVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="secondName != null  and secondName != ''"> and second_name like concat('%', #{secondName}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
        </where>
        order by sort,temp_id desc
    </select>

    <select id="selectFsFollowTempByTempId" parameterType="Long" resultMap="FsFollowTempResult">
        <include refid="selectFsFollowTempVo"/>
        where temp_id = #{tempId}
    </select>

    <insert id="insertFsFollowTemp" parameterType="FsFollowTemp">
        insert into fs_follow_temp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tempId != null">temp_id,</if>
            <if test="name != null">name,</if>
            <if test="secondName != null">second_name,</if>
            <if test="formJson != null">form_json,</if>
            <if test="sort != null">sort,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tempId != null">#{tempId},</if>
            <if test="name != null">#{name},</if>
            <if test="secondName != null">#{secondName},</if>
            <if test="formJson != null">#{formJson},</if>
            <if test="sort != null">#{sort},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateFsFollowTemp" parameterType="FsFollowTemp">
        update fs_follow_temp
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="secondName != null">second_name = #{secondName},</if>
            <if test="formJson != null">form_json = #{formJson},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where temp_id = #{tempId}
    </update>

    <delete id="deleteFsFollowTempByTempId" parameterType="Long">
        delete from fs_follow_temp where temp_id = #{tempId}
    </delete>

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