<?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.FsShippingTemplatesMapper">
    
    <resultMap type="FsShippingTemplates" id="FsShippingTemplatesResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="type"    column="type"    />
        <result property="regionInfo"    column="region_info"    />
        <result property="appoint"    column="appoint"    />
        <result property="appointInfo"    column="appoint_info"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="sort"    column="sort"    />
    </resultMap>

    <sql id="selectFsShippingTemplatesVo">
        select id, name, type, region_info, appoint, appoint_info, create_time, update_time, is_del, sort from fs_shipping_templates
    </sql>

    <select id="selectFsShippingTemplatesList" parameterType="FsShippingTemplates" resultMap="FsShippingTemplatesResult">
        <include refid="selectFsShippingTemplatesVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="regionInfo != null  and regionInfo != ''"> and region_info = #{regionInfo}</if>
            <if test="appoint != null "> and appoint = #{appoint}</if>
            <if test="appointInfo != null  and appointInfo != ''"> and appoint_info = #{appointInfo}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="sort != null "> and sort = #{sort}</if>
        </where>
    </select>
    
    <select id="selectFsShippingTemplatesById" parameterType="Long" resultMap="FsShippingTemplatesResult">
        <include refid="selectFsShippingTemplatesVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsShippingTemplates" parameterType="FsShippingTemplates" useGeneratedKeys="true" keyProperty="id">
        insert into fs_shipping_templates
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="type != null">type,</if>
            <if test="regionInfo != null">region_info,</if>
            <if test="appoint != null">appoint,</if>
            <if test="appointInfo != null">appoint_info,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="sort != null">sort,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="type != null">#{type},</if>
            <if test="regionInfo != null">#{regionInfo},</if>
            <if test="appoint != null">#{appoint},</if>
            <if test="appointInfo != null">#{appointInfo},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="sort != null">#{sort},</if>
         </trim>
    </insert>

    <update id="updateFsShippingTemplates" parameterType="FsShippingTemplates">
        update fs_shipping_templates
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="type != null">type = #{type},</if>
            <if test="regionInfo != null">region_info = #{regionInfo},</if>
            <if test="appoint != null">appoint = #{appoint},</if>
            <if test="appointInfo != null">appoint_info = #{appointInfo},</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="sort != null">sort = #{sort},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteFsShippingTemplatesById" parameterType="Long">
        update fs_shipping_templates set is_del=1 where id = #{id}
    </update>

    <delete id="deleteFsShippingTemplatesByIds" parameterType="String">
        update fs_shipping_templates set is_del=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>