<?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.FsExpressMapper">
    
    <resultMap type="FsExpress" id="FsExpressResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="sort"    column="sort"    />
        <result property="isShow"    column="is_show"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="omsCode"    column="oms_code"    />
    </resultMap>

    <sql id="selectFsExpressVo">
        select id, code, name, sort, is_show, create_time, update_time, is_del,oms_code from fs_express
    </sql>

    <select id="selectFsExpressList" parameterType="FsExpress" resultMap="FsExpressResult">
        <include refid="selectFsExpressVo"/>
        <where>  
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="isShow != null "> and is_show = #{isShow}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectFsExpressById" parameterType="Long" resultMap="FsExpressResult">
        <include refid="selectFsExpressVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsExpress" parameterType="FsExpress" useGeneratedKeys="true" keyProperty="id">
        insert into fs_express
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null and code != ''">code,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="sort != null">sort,</if>
            <if test="isShow != null">is_show,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="omsCode != null">oms_code,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null and code != ''">#{code},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="sort != null">#{sort},</if>
            <if test="isShow != null">#{isShow},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="omsCode != null">#{omsCode},</if>
         </trim>
    </insert>

    <update id="updateFsExpress" parameterType="FsExpress">
        update fs_express
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null and code != ''">code = #{code},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="isShow != null">is_show = #{isShow},</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="omsCode != null">oms_code = #{omsCode},</if>
        </trim>
        where id = #{id}
    </update>

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

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