<?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.tmerclub.cloud.order.mapper.PurchaseOrderAddrMapper">
  <resultMap id="purchaseOrderAddrMap" type="com.tmerclub.cloud.order.model.PurchaseOrderAddr">
    <id column="purchase_order_addr_id" property="purchaseOrderAddrId" />
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
    <result column="shop_id" property="shopId"/>
    <result column="consignee" property="consignee"/>
    <result column="province_id" property="provinceId"/>
    <result column="province" property="province"/>
    <result column="city_id" property="cityId"/>
    <result column="city" property="city"/>
    <result column="area_id" property="areaId"/>
    <result column="area" property="area"/>
    <result column="addr" property="addr"/>
    <result column="mobile" property="mobile"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `purchase_order_addr_id`,
    `create_time`,
    `update_time`,
    `shop_id`,
    `consignee`,
    `province_id`,
    `province`,
    `city_id`,
    `city`,
    `area_id`,
    `area`,
    `addr`,
    `mobile`
  </sql>
  <select id="getByPurchaseOrderAddrId" resultType="com.tmerclub.cloud.order.model.PurchaseOrderAddr">
    select <include refid="Vo_Column_List"/> from purchase_order_addr where purchase_order_addr_id = #{purchaseOrderAddrId}
  </select>
  <insert id="save" useGeneratedKeys="true" keyProperty="purchaseOrderAddr.purchaseOrderAddrId">
    insert into purchase_order_addr (`purchase_order_addr_id`,`shop_id`,`consignee`,`province_id`,`province`,`city_id`,`city`,`area_id`,`area`,`addr`,`mobile`)
    values (#{purchaseOrderAddr.purchaseOrderAddrId},#{purchaseOrderAddr.shopId},#{purchaseOrderAddr.consignee},#{purchaseOrderAddr.provinceId},
    #{purchaseOrderAddr.province},#{purchaseOrderAddr.cityId},#{purchaseOrderAddr.city},#{purchaseOrderAddr.areaId},#{purchaseOrderAddr.area},
    #{purchaseOrderAddr.addr},#{purchaseOrderAddr.mobile});
  </insert>
  <update id="update">
    update purchase_order_addr
    <set>
      <if test="purchaseOrderAddr.shopId != null">
        `shop_id` = #{purchaseOrderAddr.shopId},
      </if>
      <if test="purchaseOrderAddr.consignee != null">
        `consignee` = #{purchaseOrderAddr.consignee},
      </if>
      <if test="purchaseOrderAddr.provinceId != null">
        `province_id` = #{purchaseOrderAddr.provinceId},
      </if>
      <if test="purchaseOrderAddr.province != null">
        `province` = #{purchaseOrderAddr.province},
      </if>
      <if test="purchaseOrderAddr.cityId != null">
        `city_id` = #{purchaseOrderAddr.cityId},
      </if>
      <if test="purchaseOrderAddr.city != null">
        `city` = #{purchaseOrderAddr.city},
      </if>
      <if test="purchaseOrderAddr.areaId != null">
        `area_id` = #{purchaseOrderAddr.areaId},
      </if>
      <if test="purchaseOrderAddr.area != null">
        `area` = #{purchaseOrderAddr.area},
      </if>
      <if test="purchaseOrderAddr.addr != null">
        `addr` = #{purchaseOrderAddr.addr},
      </if>
      <if test="purchaseOrderAddr.mobile != null">
        `mobile` = #{purchaseOrderAddr.mobile},
      </if>
    </set>
    where purchase_order_addr_id = #{purchaseOrderAddr.purchaseOrderAddrId}
  </update>
  <delete id="deleteById">
    delete from purchase_order_addr where purchase_order_addr_id = #{purchaseOrderAddrId}
  </delete>

</mapper>
