<?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.FsShippingTemplatesFreeMapper">
    
    <resultMap type="FsShippingTemplatesFree" id="FsShippingTemplatesFreeResult">
        <result property="id"    column="id"    />
        <result property="tempId"    column="temp_id"    />
        <result property="provinceId"    column="province_id"    />
        <result property="cityId"    column="city_id"    />
        <result property="number"    column="number"    />
        <result property="price"    column="price"    />
        <result property="type"    column="type"    />
    </resultMap>

    <sql id="selectFsShippingTemplatesFreeVo">
        select id, temp_id, province_id, city_id, number, price, type from fs_shipping_templates_free
    </sql>

    <select id="selectFsShippingTemplatesFreeList" parameterType="FsShippingTemplatesFree" resultMap="FsShippingTemplatesFreeResult">
        <include refid="selectFsShippingTemplatesFreeVo"/>
        <where>  
            <if test="tempId != null "> and temp_id = #{tempId}</if>
            <if test="provinceId != null "> and province_id = #{provinceId}</if>
            <if test="cityId != null "> and city_id = #{cityId}</if>
            <if test="number != null "> and number = #{number}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="type != null "> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectFsShippingTemplatesFreeById" parameterType="Long" resultMap="FsShippingTemplatesFreeResult">
        <include refid="selectFsShippingTemplatesFreeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsShippingTemplatesFree" parameterType="FsShippingTemplatesFree" useGeneratedKeys="true" keyProperty="id">
        insert into fs_shipping_templates_free
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tempId != null">temp_id,</if>
            <if test="provinceId != null">province_id,</if>
            <if test="cityId != null">city_id,</if>
            <if test="number != null">number,</if>
            <if test="price != null">price,</if>
            <if test="type != null">type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tempId != null">#{tempId},</if>
            <if test="provinceId != null">#{provinceId},</if>
            <if test="cityId != null">#{cityId},</if>
            <if test="number != null">#{number},</if>
            <if test="price != null">#{price},</if>
            <if test="type != null">#{type},</if>
         </trim>
    </insert>

    <update id="updateFsShippingTemplatesFree" parameterType="FsShippingTemplatesFree">
        update fs_shipping_templates_free
        <trim prefix="SET" suffixOverrides=",">
            <if test="tempId != null">temp_id = #{tempId},</if>
            <if test="provinceId != null">province_id = #{provinceId},</if>
            <if test="cityId != null">city_id = #{cityId},</if>
            <if test="number != null">number = #{number},</if>
            <if test="price != null">price = #{price},</if>
            <if test="type != null">type = #{type},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsShippingTemplatesFreeById" parameterType="Long">
        delete from fs_shipping_templates_free where id = #{id}
    </delete>

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