<?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.PlatformPurchaseOrderAddressMapper">

    <resultMap id="BaseResultMap" type="com.ms.dal.entity.PlatformPurchaseOrderAddress">
            <id property="purOrderId" column="pur_order_id" jdbcType="VARCHAR"/>
            <result property="shopId" column="shop_id" jdbcType="BIGINT"/>
            <result property="provinceName" column="province_name" jdbcType="VARCHAR"/>
            <result property="provinceId" column="province_id" jdbcType="VARCHAR"/>
            <result property="cityId" column="city_id" jdbcType="VARCHAR"/>
            <result property="cityName" column="city_name" jdbcType="VARCHAR"/>
            <result property="townName" column="town_name" jdbcType="VARCHAR"/>
            <result property="townId" column="town_id" jdbcType="VARCHAR"/>
            <result property="streetId" column="street_id" jdbcType="VARCHAR"/>
            <result property="streetName" column="street_name" jdbcType="VARCHAR"/>
            <result property="encryptDetail" column="encrypt_detail" jdbcType="VARCHAR"/>
            <result property="postTel" column="post_tel" jdbcType="VARCHAR"/>
            <result property="postReceiver" column="post_receiver" jdbcType="VARCHAR"/>
            <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
            <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        pur_order_id,shop_id,province_name,
        province_id,city_id,city_name,
        town_name,town_id,street_id,
        street_name,encrypt_detail,post_tel,
        post_receiver,gmt_create,gmt_modified
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from platform_purchase_order_address
        where  pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from platform_purchase_order_address
        where  pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </delete>
    <insert id="insert" keyColumn="pur_order_id" keyProperty="purOrderId" parameterType="com.ms.dal.entity.PlatformPurchaseOrderAddress" useGeneratedKeys="true">
        insert into platform_purchase_order_address
        ( pur_order_id,shop_id,province_name
        ,province_id,city_id,city_name
        ,town_name,town_id,street_id
        ,street_name,encrypt_detail,post_tel
        ,post_receiver,gmt_create,gmt_modified
        )
        values (#{purOrderId,jdbcType=VARCHAR},#{shopId,jdbcType=BIGINT},#{provinceName,jdbcType=VARCHAR}
        ,#{provinceId,jdbcType=VARCHAR},#{cityId,jdbcType=VARCHAR},#{cityName,jdbcType=VARCHAR}
        ,#{townName,jdbcType=VARCHAR},#{townId,jdbcType=VARCHAR},#{streetId,jdbcType=VARCHAR}
        ,#{streetName,jdbcType=VARCHAR},#{encryptDetail,jdbcType=VARCHAR},#{postTel,jdbcType=VARCHAR}
        ,#{postReceiver,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP}
        )
    </insert>
    <update id="insertOrUpdate"  keyColumn="pur_order_id" keyProperty="purOrderId" parameterType="com.ms.dal.entity.PlatformPurchaseOrderAddress"
        useGeneratedKeys="true">
        insert into platform_purchase_order_address
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">pur_order_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="provinceName != null">province_name,</if>
                <if test="provinceId != null">province_id,</if>
                <if test="cityId != null">city_id,</if>
                <if test="cityName != null">city_name,</if>
                <if test="townName != null">town_name,</if>
                <if test="townId != null">town_id,</if>
                <if test="streetId != null">street_id,</if>
                <if test="streetName != null">street_name,</if>
                <if test="encryptDetail != null">encrypt_detail,</if>
                <if test="postTel != null">post_tel,</if>
                <if test="postReceiver != null">post_receiver,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">#{purOrderId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="provinceName != null">#{provinceName,jdbcType=VARCHAR},</if>
                <if test="provinceId != null">#{provinceId,jdbcType=VARCHAR},</if>
                <if test="cityId != null">#{cityId,jdbcType=VARCHAR},</if>
                <if test="cityName != null">#{cityName,jdbcType=VARCHAR},</if>
                <if test="townName != null">#{townName,jdbcType=VARCHAR},</if>
                <if test="townId != null">#{townId,jdbcType=VARCHAR},</if>
                <if test="streetId != null">#{streetId,jdbcType=VARCHAR},</if>
                <if test="streetName != null">#{streetName,jdbcType=VARCHAR},</if>
                <if test="encryptDetail != null">#{encryptDetail,jdbcType=VARCHAR},</if>
                <if test="postTel != null">#{postTel,jdbcType=VARCHAR},</if>
                <if test="postReceiver != null">#{postReceiver,jdbcType=VARCHAR},</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="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="provinceName != null">
                    province_name = #{provinceName,jdbcType=VARCHAR},
                </if>
                <if test="provinceId != null">
                    province_id = #{provinceId,jdbcType=VARCHAR},
                </if>
                <if test="cityId != null">
                    city_id = #{cityId,jdbcType=VARCHAR},
                </if>
                <if test="cityName != null">
                    city_name = #{cityName,jdbcType=VARCHAR},
                </if>
                <if test="townName != null">
                    town_name = #{townName,jdbcType=VARCHAR},
                </if>
                <if test="townId != null">
                    town_id = #{townId,jdbcType=VARCHAR},
                </if>
                <if test="streetId != null">
                    street_id = #{streetId,jdbcType=VARCHAR},
                </if>
                <if test="streetName != null">
                    street_name = #{streetName,jdbcType=VARCHAR},
                </if>
                <if test="encryptDetail != null">
                    encrypt_detail = #{encryptDetail,jdbcType=VARCHAR},
                </if>
                <if test="postTel != null">
                    post_tel = #{postTel,jdbcType=VARCHAR},
                </if>
                <if test="postReceiver != null">
                    post_receiver = #{postReceiver,jdbcType=VARCHAR},
                </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="pur_order_id" keyProperty="purOrderId" parameterType="com.ms.dal.entity.PlatformPurchaseOrderAddress" useGeneratedKeys="true">
        insert into platform_purchase_order_address
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">pur_order_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="provinceName != null">province_name,</if>
                <if test="provinceId != null">province_id,</if>
                <if test="cityId != null">city_id,</if>
                <if test="cityName != null">city_name,</if>
                <if test="townName != null">town_name,</if>
                <if test="townId != null">town_id,</if>
                <if test="streetId != null">street_id,</if>
                <if test="streetName != null">street_name,</if>
                <if test="encryptDetail != null">encrypt_detail,</if>
                <if test="postTel != null">post_tel,</if>
                <if test="postReceiver != null">post_receiver,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">#{purOrderId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="provinceName != null">#{provinceName,jdbcType=VARCHAR},</if>
                <if test="provinceId != null">#{provinceId,jdbcType=VARCHAR},</if>
                <if test="cityId != null">#{cityId,jdbcType=VARCHAR},</if>
                <if test="cityName != null">#{cityName,jdbcType=VARCHAR},</if>
                <if test="townName != null">#{townName,jdbcType=VARCHAR},</if>
                <if test="townId != null">#{townId,jdbcType=VARCHAR},</if>
                <if test="streetId != null">#{streetId,jdbcType=VARCHAR},</if>
                <if test="streetName != null">#{streetName,jdbcType=VARCHAR},</if>
                <if test="encryptDetail != null">#{encryptDetail,jdbcType=VARCHAR},</if>
                <if test="postTel != null">#{postTel,jdbcType=VARCHAR},</if>
                <if test="postReceiver != null">#{postReceiver,jdbcType=VARCHAR},</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.PlatformPurchaseOrderAddress">
        update platform_purchase_order_address
        <set>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="provinceName != null">
                    province_name = #{provinceName,jdbcType=VARCHAR},
                </if>
                <if test="provinceId != null">
                    province_id = #{provinceId,jdbcType=VARCHAR},
                </if>
                <if test="cityId != null">
                    city_id = #{cityId,jdbcType=VARCHAR},
                </if>
                <if test="cityName != null">
                    city_name = #{cityName,jdbcType=VARCHAR},
                </if>
                <if test="townName != null">
                    town_name = #{townName,jdbcType=VARCHAR},
                </if>
                <if test="townId != null">
                    town_id = #{townId,jdbcType=VARCHAR},
                </if>
                <if test="streetId != null">
                    street_id = #{streetId,jdbcType=VARCHAR},
                </if>
                <if test="streetName != null">
                    street_name = #{streetName,jdbcType=VARCHAR},
                </if>
                <if test="encryptDetail != null">
                    encrypt_detail = #{encryptDetail,jdbcType=VARCHAR},
                </if>
                <if test="postTel != null">
                    post_tel = #{postTel,jdbcType=VARCHAR},
                </if>
                <if test="postReceiver != null">
                    post_receiver = #{postReceiver,jdbcType=VARCHAR},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.PlatformPurchaseOrderAddress">
        update platform_purchase_order_address
        set 
            shop_id =  #{shopId,jdbcType=BIGINT},
            province_name =  #{provinceName,jdbcType=VARCHAR},
            province_id =  #{provinceId,jdbcType=VARCHAR},
            city_id =  #{cityId,jdbcType=VARCHAR},
            city_name =  #{cityName,jdbcType=VARCHAR},
            town_name =  #{townName,jdbcType=VARCHAR},
            town_id =  #{townId,jdbcType=VARCHAR},
            street_id =  #{streetId,jdbcType=VARCHAR},
            street_name =  #{streetName,jdbcType=VARCHAR},
            encrypt_detail =  #{encryptDetail,jdbcType=VARCHAR},
            post_tel =  #{postTel,jdbcType=VARCHAR},
            post_receiver =  #{postReceiver,jdbcType=VARCHAR},
            gmt_create =  #{gmtCreate,jdbcType=TIMESTAMP},
            gmt_modified =  #{gmtModified,jdbcType=TIMESTAMP}
        where   pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </update>
</mapper>
