<?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.yonge.cooleshow.mbg.mapper.OmsOrderCourierMapper">
  <resultMap id="BaseResultMap" type="com.yonge.cooleshow.mbg.model.OmsOrderCourier">
    <!--@mbg.generated-->
    <!--@Table oms_order_courier-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="company" jdbcType="VARCHAR" property="company" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="courier_no" jdbcType="VARCHAR" property="courierNo" />
    <result column="logistics" jdbcType="LONGVARCHAR" property="logistics" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, company, order_id, courier_no, logistics
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from oms_order_courier
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from oms_order_courier
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderCourier" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into oms_order_courier (company, order_id, courier_no, 
      logistics)
    values (#{company,jdbcType=VARCHAR}, #{orderId,jdbcType=BIGINT}, #{courierNo,jdbcType=VARCHAR}, 
      #{logistics,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderCourier" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into oms_order_courier
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="company != null">
        company,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="courierNo != null">
        courier_no,
      </if>
      <if test="logistics != null">
        logistics,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="company != null">
        #{company,jdbcType=VARCHAR},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="courierNo != null">
        #{courierNo,jdbcType=VARCHAR},
      </if>
      <if test="logistics != null">
        #{logistics,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderCourier">
    <!--@mbg.generated-->
    update oms_order_courier
    <set>
      <if test="company != null">
        company = #{company,jdbcType=VARCHAR},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="courierNo != null">
        courier_no = #{courierNo,jdbcType=VARCHAR},
      </if>
      <if test="logistics != null">
        logistics = #{logistics,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderCourier">
    <!--@mbg.generated-->
    update oms_order_courier
    set company = #{company,jdbcType=VARCHAR},
      order_id = #{orderId,jdbcType=BIGINT},
      courier_no = #{courierNo,jdbcType=VARCHAR},
      logistics = #{logistics,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into oms_order_courier
    (company, order_id, courier_no, logistics)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.company,jdbcType=VARCHAR}, #{item.orderId,jdbcType=BIGINT}, #{item.courierNo,jdbcType=VARCHAR}, 
        #{item.logistics,jdbcType=LONGVARCHAR})
    </foreach>
  </insert>

  <update id="updateByCourierNo">
    update oms_order_courier set logistics = #{logistics} where courier_no = #{courierNo};
  </update>

  <select id="queryByCourierNo" resultMap="BaseResultMap">
    select * from oms_order_courier where courier_no = #{courierNo} order by  id desc limit  1
    </select>
</mapper>