<?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.ms.dal.mapper.LogisticsMapper">

    <resultMap id="BaseResultMap" type="com.ms.dal.entity.Logistics">
            <id property="logisticsId" column="logistics_id" jdbcType="BIGINT"/>
            <result property="logisticsName" column="logistics_name" jdbcType="VARCHAR"/>
            <result property="logisticsCode" column="logistics_code" jdbcType="VARCHAR"/>
            <result property="status" column="status" jdbcType="VARCHAR"/>
            <result property="sort" column="sort" jdbcType="INTEGER"/>
            <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
            <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        logistics_id,logistics_name,logistics_code,
        status,sort,gmt_create,
        gmt_modified
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from logistics
        where  logistics_id = #{logisticsId,jdbcType=BIGINT} 
    </select>
    <select id="getList" resultType="com.ms.dal.entity.Logistics">
        select
        <include refid="Base_Column_List" />
        from logistics
    </select>
    <select id="getByLogisticsName" resultType="com.ms.dal.entity.Logistics">
        select
        <include refid="Base_Column_List" />
        from logistics
        where  logistics_name = #{logisticsName,jdbcType=VARCHAR}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from logistics
        where  logistics_id = #{logisticsId,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="logistics_id" keyProperty="logisticsId" parameterType="com.ms.dal.entity.Logistics" useGeneratedKeys="true">
        insert into logistics
        ( logistics_id,logistics_name,logistics_code
        ,status,sort,gmt_create
        ,gmt_modified)
        values (#{logisticsId,jdbcType=BIGINT},#{logisticsName,jdbcType=VARCHAR},#{logisticsCode,jdbcType=VARCHAR}
        ,#{status,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER},#{gmtCreate,jdbcType=TIMESTAMP}
        ,#{gmtModified,jdbcType=TIMESTAMP})
    </insert>
    <update id="insertOrUpdate"  keyColumn="logistics_id" keyProperty="logisticsId" parameterType="com.ms.dal.entity.Logistics"
        useGeneratedKeys="true">
        insert into logistics
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="logisticsId != null">logistics_id,</if>
                <if test="logisticsName != null">logistics_name,</if>
                <if test="logisticsCode != null">logistics_code,</if>
                <if test="status != null">status,</if>
                <if test="sort != null">sort,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="logisticsId != null">#{logisticsId,jdbcType=BIGINT},</if>
                <if test="logisticsName != null">#{logisticsName,jdbcType=VARCHAR},</if>
                <if test="logisticsCode != null">#{logisticsCode,jdbcType=VARCHAR},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="sort != null">#{sort,jdbcType=INTEGER},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
        ON DUPLICATE KEY UPDATE
        <trim  suffixOverrides=",">
                <if test="logisticsName != null">
                    logistics_name = #{logisticsName,jdbcType=VARCHAR},
                </if>
                <if test="logisticsCode != null">
                    logistics_code = #{logisticsCode,jdbcType=VARCHAR},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="sort != null">
                    sort = #{sort,jdbcType=INTEGER},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </trim>
    </update>
    <insert id="insertSelective" keyColumn="logistics_id" keyProperty="logisticsId" parameterType="com.ms.dal.entity.Logistics" useGeneratedKeys="true">
        insert into logistics
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="logisticsId != null">logistics_id,</if>
                <if test="logisticsName != null">logistics_name,</if>
                <if test="logisticsCode != null">logistics_code,</if>
                <if test="status != null">status,</if>
                <if test="sort != null">sort,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="logisticsId != null">#{logisticsId,jdbcType=BIGINT},</if>
                <if test="logisticsName != null">#{logisticsName,jdbcType=VARCHAR},</if>
                <if test="logisticsCode != null">#{logisticsCode,jdbcType=VARCHAR},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="sort != null">#{sort,jdbcType=INTEGER},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.Logistics">
        update logistics
        <set>
                <if test="logisticsName != null">
                    logistics_name = #{logisticsName,jdbcType=VARCHAR},
                </if>
                <if test="logisticsCode != null">
                    logistics_code = #{logisticsCode,jdbcType=VARCHAR},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="sort != null">
                    sort = #{sort,jdbcType=INTEGER},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   logistics_id = #{logisticsId,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.Logistics">
        update logistics
        set 
            logistics_name =  #{logisticsName,jdbcType=VARCHAR},
            logistics_code =  #{logisticsCode,jdbcType=VARCHAR},
            status =  #{status,jdbcType=VARCHAR},
            sort =  #{sort,jdbcType=INTEGER},
            gmt_create =  #{gmtCreate,jdbcType=TIMESTAMP},
            gmt_modified =  #{gmtModified,jdbcType=TIMESTAMP}
        where   logistics_id = #{logisticsId,jdbcType=BIGINT} 
    </update>
</mapper>
