<?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.neusoft.smart.pos.order.persistent.mapper.OrderDeliveryMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.order.persistent.domain.OrderDelivery">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="order_number" jdbcType="VARCHAR" property="orderNumber" />
    <result column="address_id" jdbcType="INTEGER" property="addressId" />
    <result column="contacts" jdbcType="VARCHAR" property="contacts" />
    <result column="contact_phone" jdbcType="VARCHAR" property="contactPhone" />
    <result column="detailed_address" jdbcType="VARCHAR" property="detailedAddress" />
    <result column="create_at" jdbcType="TIMESTAMP" property="createAt" />
    <result column="delivery_type" jdbcType="VARCHAR" property="deliveryType" />
    <result column="delivery_type_param" jdbcType="VARCHAR" property="deliveryTypeParam" />
    <result column="deliver_name" jdbcType="VARCHAR" property="deliverName" />
    <result column="deliver_phone" jdbcType="VARCHAR" property="deliverPhone" />
    <result column="deliver_uid" jdbcType="VARCHAR" property="deliverUid" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_at" jdbcType="TIMESTAMP" property="updateAt" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, order_number, address_id, contacts, contact_phone, detailed_address, create_at, 
    delivery_type, delivery_type_param, deliver_name, deliver_phone, deliver_uid, create_by, 
    update_by, update_at
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.order.persistent.domain.OrderDeliveryExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from order_delivery
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="offset != null and limit != null">
      limit ${offset}, ${limit}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from order_delivery
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from order_delivery
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.order.persistent.domain.OrderDeliveryExample">
    delete from order_delivery
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.order.persistent.domain.OrderDelivery" useGeneratedKeys="true">
    insert into order_delivery (order_number, address_id, contacts, 
      contact_phone, detailed_address, create_at, 
      delivery_type, delivery_type_param, deliver_name, 
      deliver_phone, deliver_uid, create_by, 
      update_by, update_at)
    values (#{orderNumber,jdbcType=VARCHAR}, #{addressId,jdbcType=INTEGER}, #{contacts,jdbcType=VARCHAR}, 
      #{contactPhone,jdbcType=VARCHAR}, #{detailedAddress,jdbcType=VARCHAR}, #{createAt,jdbcType=TIMESTAMP}, 
      #{deliveryType,jdbcType=VARCHAR}, #{deliveryTypeParam,jdbcType=VARCHAR}, #{deliverName,jdbcType=VARCHAR}, 
      #{deliverPhone,jdbcType=VARCHAR}, #{deliverUid,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, 
      #{updateBy,jdbcType=VARCHAR}, #{updateAt,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.order.persistent.domain.OrderDelivery" useGeneratedKeys="true">
    insert into order_delivery
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderNumber != null">
        order_number,
      </if>
      <if test="addressId != null">
        address_id,
      </if>
      <if test="contacts != null">
        contacts,
      </if>
      <if test="contactPhone != null">
        contact_phone,
      </if>
      <if test="detailedAddress != null">
        detailed_address,
      </if>
      <if test="createAt != null">
        create_at,
      </if>
      <if test="deliveryType != null">
        delivery_type,
      </if>
      <if test="deliveryTypeParam != null">
        delivery_type_param,
      </if>
      <if test="deliverName != null">
        deliver_name,
      </if>
      <if test="deliverPhone != null">
        deliver_phone,
      </if>
      <if test="deliverUid != null">
        deliver_uid,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateAt != null">
        update_at,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderNumber != null">
        #{orderNumber,jdbcType=VARCHAR},
      </if>
      <if test="addressId != null">
        #{addressId,jdbcType=INTEGER},
      </if>
      <if test="contacts != null">
        #{contacts,jdbcType=VARCHAR},
      </if>
      <if test="contactPhone != null">
        #{contactPhone,jdbcType=VARCHAR},
      </if>
      <if test="detailedAddress != null">
        #{detailedAddress,jdbcType=VARCHAR},
      </if>
      <if test="createAt != null">
        #{createAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deliveryType != null">
        #{deliveryType,jdbcType=VARCHAR},
      </if>
      <if test="deliveryTypeParam != null">
        #{deliveryTypeParam,jdbcType=VARCHAR},
      </if>
      <if test="deliverName != null">
        #{deliverName,jdbcType=VARCHAR},
      </if>
      <if test="deliverPhone != null">
        #{deliverPhone,jdbcType=VARCHAR},
      </if>
      <if test="deliverUid != null">
        #{deliverUid,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateAt != null">
        #{updateAt,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.order.persistent.domain.OrderDeliveryExample" resultType="java.lang.Integer">
    select count(*) from order_delivery
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update order_delivery
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.orderNumber != null">
        order_number = #{record.orderNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.addressId != null">
        address_id = #{record.addressId,jdbcType=INTEGER},
      </if>
      <if test="record.contacts != null">
        contacts = #{record.contacts,jdbcType=VARCHAR},
      </if>
      <if test="record.contactPhone != null">
        contact_phone = #{record.contactPhone,jdbcType=VARCHAR},
      </if>
      <if test="record.detailedAddress != null">
        detailed_address = #{record.detailedAddress,jdbcType=VARCHAR},
      </if>
      <if test="record.createAt != null">
        create_at = #{record.createAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deliveryType != null">
        delivery_type = #{record.deliveryType,jdbcType=VARCHAR},
      </if>
      <if test="record.deliveryTypeParam != null">
        delivery_type_param = #{record.deliveryTypeParam,jdbcType=VARCHAR},
      </if>
      <if test="record.deliverName != null">
        deliver_name = #{record.deliverName,jdbcType=VARCHAR},
      </if>
      <if test="record.deliverPhone != null">
        deliver_phone = #{record.deliverPhone,jdbcType=VARCHAR},
      </if>
      <if test="record.deliverUid != null">
        deliver_uid = #{record.deliverUid,jdbcType=VARCHAR},
      </if>
      <if test="record.createBy != null">
        create_by = #{record.createBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updateBy != null">
        update_by = #{record.updateBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updateAt != null">
        update_at = #{record.updateAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update order_delivery
    set id = #{record.id,jdbcType=INTEGER},
      order_number = #{record.orderNumber,jdbcType=VARCHAR},
      address_id = #{record.addressId,jdbcType=INTEGER},
      contacts = #{record.contacts,jdbcType=VARCHAR},
      contact_phone = #{record.contactPhone,jdbcType=VARCHAR},
      detailed_address = #{record.detailedAddress,jdbcType=VARCHAR},
      create_at = #{record.createAt,jdbcType=TIMESTAMP},
      delivery_type = #{record.deliveryType,jdbcType=VARCHAR},
      delivery_type_param = #{record.deliveryTypeParam,jdbcType=VARCHAR},
      deliver_name = #{record.deliverName,jdbcType=VARCHAR},
      deliver_phone = #{record.deliverPhone,jdbcType=VARCHAR},
      deliver_uid = #{record.deliverUid,jdbcType=VARCHAR},
      create_by = #{record.createBy,jdbcType=VARCHAR},
      update_by = #{record.updateBy,jdbcType=VARCHAR},
      update_at = #{record.updateAt,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.order.persistent.domain.OrderDelivery">
    update order_delivery
    <set>
      <if test="orderNumber != null">
        order_number = #{orderNumber,jdbcType=VARCHAR},
      </if>
      <if test="addressId != null">
        address_id = #{addressId,jdbcType=INTEGER},
      </if>
      <if test="contacts != null">
        contacts = #{contacts,jdbcType=VARCHAR},
      </if>
      <if test="contactPhone != null">
        contact_phone = #{contactPhone,jdbcType=VARCHAR},
      </if>
      <if test="detailedAddress != null">
        detailed_address = #{detailedAddress,jdbcType=VARCHAR},
      </if>
      <if test="createAt != null">
        create_at = #{createAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deliveryType != null">
        delivery_type = #{deliveryType,jdbcType=VARCHAR},
      </if>
      <if test="deliveryTypeParam != null">
        delivery_type_param = #{deliveryTypeParam,jdbcType=VARCHAR},
      </if>
      <if test="deliverName != null">
        deliver_name = #{deliverName,jdbcType=VARCHAR},
      </if>
      <if test="deliverPhone != null">
        deliver_phone = #{deliverPhone,jdbcType=VARCHAR},
      </if>
      <if test="deliverUid != null">
        deliver_uid = #{deliverUid,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateAt != null">
        update_at = #{updateAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.order.persistent.domain.OrderDelivery">
    update order_delivery
    set order_number = #{orderNumber,jdbcType=VARCHAR},
      address_id = #{addressId,jdbcType=INTEGER},
      contacts = #{contacts,jdbcType=VARCHAR},
      contact_phone = #{contactPhone,jdbcType=VARCHAR},
      detailed_address = #{detailedAddress,jdbcType=VARCHAR},
      create_at = #{createAt,jdbcType=TIMESTAMP},
      delivery_type = #{deliveryType,jdbcType=VARCHAR},
      delivery_type_param = #{deliveryTypeParam,jdbcType=VARCHAR},
      deliver_name = #{deliverName,jdbcType=VARCHAR},
      deliver_phone = #{deliverPhone,jdbcType=VARCHAR},
      deliver_uid = #{deliverUid,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_at = #{updateAt,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into order_delivery  (order_number, address_id, contacts, 
        contact_phone, detailed_address, create_at, 
        delivery_type, delivery_type_param, deliver_name, 
        deliver_phone, deliver_uid, create_by, 
        update_by, update_at)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.orderNumber,jdbcType=VARCHAR}, #{item.addressId,jdbcType=INTEGER}, #{item.contacts,jdbcType=VARCHAR}, 
        #{item.contactPhone,jdbcType=VARCHAR}, #{item.detailedAddress,jdbcType=VARCHAR}, #{item.createAt,jdbcType=TIMESTAMP}, 
        #{item.deliveryType,jdbcType=VARCHAR}, #{item.deliveryTypeParam,jdbcType=VARCHAR}, #{item.deliverName,jdbcType=VARCHAR}, 
        #{item.deliverPhone,jdbcType=VARCHAR}, #{item.deliverUid,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR}, 
        #{item.updateBy,jdbcType=VARCHAR}, #{item.updateAt,jdbcType=TIMESTAMP})
      </foreach>
    </if>
  </insert>
</mapper>