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

    <resultMap type="FsTestTemp" id="FsTestTempResult">
        <result property="tempId"    column="temp_id"    />
        <result property="name"    column="name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="itemTypeJson"    column="item_type_json"    />
        <result property="tempCode"    column="temp_code"    />
        <result property="num" column="num" />
        <result property="peopleNum" column="people_num" />
        <result property="img" column="img" />
        <result property="time" column="time" />
        <result property="descs" column="descs" />
        <result property="title" column="title" />
        <result property="msg" column="msg" />
        <result property="sort" column="sort" />
    </resultMap>

    <sql id="selectFsTestTempVo">
        select temp_id,item_type_json,msg,sort,title,descs,`time`,img,people_num, num,temp_code,name, create_time, update_time, status, remark from fs_test_temp
    </sql>

    <select id="selectFsTestTempList" parameterType="FsTestTemp" resultMap="FsTestTempResult">
        <include refid="selectFsTestTempVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
        order by sort asc,temp_id desc
    </select>

    <select id="selectFsTestTempByTempId" parameterType="Long" resultMap="FsTestTempResult">
        <include refid="selectFsTestTempVo"/>
        where temp_id = #{tempId}
    </select>

    <insert id="insertFsTestTemp" parameterType="FsTestTemp" useGeneratedKeys="true" keyProperty="tempId">
        insert into fs_test_temp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="itemTypeJson != null">item_type_json,</if>
            <if test="tempCode != null">temp_code,</if>
            <if test="num != null">num,</if>
            <if test="peopleNum != null">people_num,</if>
            <if test="img != null">img,</if>
            <if test="time != null">`time`,</if>
            <if test="descs != null">descs,</if>
            <if test="title != null">title,</if>
            <if test="msg != null">msg,</if>
            <if test="sort != null">sort,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="itemTypeJson != null">#{itemTypeJson},</if>
            <if test="tempCode != null">#{tempCode},</if>
            <if test="num != null">#{num},</if>
            <if test="peopleNum != null">#{peopleNum},</if>
            <if test="img != null">#{img},</if>
            <if test="time != null">#{time},</if>
            <if test="descs != null">#{descs},</if>
            <if test="title != null">#{title},</if>
            <if test="msg != null">#{msg},</if>
            <if test="sort != null">#{sort},</if>
         </trim>
    </insert>

    <update id="updateFsTestTemp" parameterType="FsTestTemp">
        update fs_test_temp
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="itemTypeJson != null">item_type_json = #{itemTypeJson},</if>
            <if test="tempCode != null">temp_code = #{tempCode},</if>
            <if test="num != null">num = #{num},</if>
            <if test="peopleNum != null">people_num = #{peopleNum},</if>
            <if test="img != null">img = #{img},</if>
            <if test="time != null">`time` = #{time},</if>
            <if test="descs != null">descs = #{descs},</if>
            <if test="title != null">title = #{title},</if>
            <if test="msg != null">msg = #{msg},</if>
            <if test="sort != null">sort = #{sort},</if>
        </trim>
        where temp_id = #{tempId}
    </update>

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

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