<?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.address.persistent.mapper.UserCargoAddressMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddress">
    <id column="address_id" jdbcType="INTEGER" property="addressId" />
    <result column="tag" jdbcType="VARCHAR" property="tag" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="contacts" jdbcType="VARCHAR" property="contacts" />
    <result column="contact_phone" jdbcType="VARCHAR" property="contactPhone" />
    <result column="province_code" jdbcType="VARCHAR" property="provinceCode" />
    <result column="province" jdbcType="VARCHAR" property="province" />
    <result column="city_code" jdbcType="VARCHAR" property="cityCode" />
    <result column="city" jdbcType="VARCHAR" property="city" />
    <result column="country_code" jdbcType="VARCHAR" property="countryCode" />
    <result column="country" jdbcType="VARCHAR" property="country" />
    <result column="area_code" jdbcType="VARCHAR" property="areaCode" />
    <result column="area" jdbcType="VARCHAR" property="area" />
    <result column="detailed_address" jdbcType="VARCHAR" property="detailedAddress" />
    <result column="address_type" jdbcType="INTEGER" property="addressType" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_userid" jdbcType="INTEGER" property="updateUserid" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="priority" jdbcType="INTEGER" property="priority" />
  </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">
    address_id, tag, user_id, contacts, contact_phone, province_code, province, city_code, 
    city, country_code, country, area_code, area, detailed_address, address_type, update_time, 
    update_userid, create_time, priority
  </sql>

  <select id="selectByExample" parameterType="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddressExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from user_cargo_address
    <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 user_cargo_address
    where address_id = #{addressId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from user_cargo_address
    where address_id = #{addressId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddressExample">
    delete from user_cargo_address
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="address_id" keyProperty="addressId" parameterType="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddress" useGeneratedKeys="true">
    insert into user_cargo_address (tag, user_id, contacts, 
      contact_phone, province_code, province, 
      city_code, city, country_code, 
      country, area_code, area, 
      detailed_address, address_type, update_time, 
      update_userid, create_time, priority
      )
    values (#{tag,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}, #{contacts,jdbcType=VARCHAR}, 
      #{contactPhone,jdbcType=VARCHAR}, #{provinceCode,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, 
      #{cityCode,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{countryCode,jdbcType=VARCHAR}, 
      #{country,jdbcType=VARCHAR}, #{areaCode,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR}, 
      #{detailedAddress,jdbcType=VARCHAR}, #{addressType,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, 
      #{updateUserid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{priority,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" keyColumn="address_id" keyProperty="addressId" parameterType="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddress" useGeneratedKeys="true">
    insert into user_cargo_address
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="tag != null">
        tag,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="contacts != null">
        contacts,
      </if>
      <if test="contactPhone != null">
        contact_phone,
      </if>
      <if test="provinceCode != null">
        province_code,
      </if>
      <if test="province != null">
        province,
      </if>
      <if test="cityCode != null">
        city_code,
      </if>
      <if test="city != null">
        city,
      </if>
      <if test="countryCode != null">
        country_code,
      </if>
      <if test="country != null">
        country,
      </if>
      <if test="areaCode != null">
        area_code,
      </if>
      <if test="area != null">
        area,
      </if>
      <if test="detailedAddress != null">
        detailed_address,
      </if>
      <if test="addressType != null">
        address_type,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateUserid != null">
        update_userid,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="priority != null">
        priority,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="tag != null">
        #{tag,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="contacts != null">
        #{contacts,jdbcType=VARCHAR},
      </if>
      <if test="contactPhone != null">
        #{contactPhone,jdbcType=VARCHAR},
      </if>
      <if test="provinceCode != null">
        #{provinceCode,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        #{province,jdbcType=VARCHAR},
      </if>
      <if test="cityCode != null">
        #{cityCode,jdbcType=VARCHAR},
      </if>
      <if test="city != null">
        #{city,jdbcType=VARCHAR},
      </if>
      <if test="countryCode != null">
        #{countryCode,jdbcType=VARCHAR},
      </if>
      <if test="country != null">
        #{country,jdbcType=VARCHAR},
      </if>
      <if test="areaCode != null">
        #{areaCode,jdbcType=VARCHAR},
      </if>
      <if test="area != null">
        #{area,jdbcType=VARCHAR},
      </if>
      <if test="detailedAddress != null">
        #{detailedAddress,jdbcType=VARCHAR},
      </if>
      <if test="addressType != null">
        #{addressType,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserid != null">
        #{updateUserid,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="priority != null">
        #{priority,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddressExample" resultType="java.lang.Integer">
    select count(*) from user_cargo_address
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update user_cargo_address
    <set>
      <if test="record.addressId != null">
        address_id = #{record.addressId,jdbcType=INTEGER},
      </if>
      <if test="record.tag != null">
        tag = #{record.tag,jdbcType=VARCHAR},
      </if>
      <if test="record.userId != null">
        user_id = #{record.userId,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.provinceCode != null">
        province_code = #{record.provinceCode,jdbcType=VARCHAR},
      </if>
      <if test="record.province != null">
        province = #{record.province,jdbcType=VARCHAR},
      </if>
      <if test="record.cityCode != null">
        city_code = #{record.cityCode,jdbcType=VARCHAR},
      </if>
      <if test="record.city != null">
        city = #{record.city,jdbcType=VARCHAR},
      </if>
      <if test="record.countryCode != null">
        country_code = #{record.countryCode,jdbcType=VARCHAR},
      </if>
      <if test="record.country != null">
        country = #{record.country,jdbcType=VARCHAR},
      </if>
      <if test="record.areaCode != null">
        area_code = #{record.areaCode,jdbcType=VARCHAR},
      </if>
      <if test="record.area != null">
        area = #{record.area,jdbcType=VARCHAR},
      </if>
      <if test="record.detailedAddress != null">
        detailed_address = #{record.detailedAddress,jdbcType=VARCHAR},
      </if>
      <if test="record.addressType != null">
        address_type = #{record.addressType,jdbcType=INTEGER},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateUserid != null">
        update_userid = #{record.updateUserid,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.priority != null">
        priority = #{record.priority,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update user_cargo_address
    set address_id = #{record.addressId,jdbcType=INTEGER},
      tag = #{record.tag,jdbcType=VARCHAR},
      user_id = #{record.userId,jdbcType=INTEGER},
      contacts = #{record.contacts,jdbcType=VARCHAR},
      contact_phone = #{record.contactPhone,jdbcType=VARCHAR},
      province_code = #{record.provinceCode,jdbcType=VARCHAR},
      province = #{record.province,jdbcType=VARCHAR},
      city_code = #{record.cityCode,jdbcType=VARCHAR},
      city = #{record.city,jdbcType=VARCHAR},
      country_code = #{record.countryCode,jdbcType=VARCHAR},
      country = #{record.country,jdbcType=VARCHAR},
      area_code = #{record.areaCode,jdbcType=VARCHAR},
      area = #{record.area,jdbcType=VARCHAR},
      detailed_address = #{record.detailedAddress,jdbcType=VARCHAR},
      address_type = #{record.addressType,jdbcType=INTEGER},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      update_userid = #{record.updateUserid,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      priority = #{record.priority,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddress">
    update user_cargo_address
    <set>
      <if test="tag != null">
        tag = #{tag,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="contacts != null">
        contacts = #{contacts,jdbcType=VARCHAR},
      </if>
      <if test="contactPhone != null">
        contact_phone = #{contactPhone,jdbcType=VARCHAR},
      </if>
      <if test="provinceCode != null">
        province_code = #{provinceCode,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        province = #{province,jdbcType=VARCHAR},
      </if>
      <if test="cityCode != null">
        city_code = #{cityCode,jdbcType=VARCHAR},
      </if>
      <if test="city != null">
        city = #{city,jdbcType=VARCHAR},
      </if>
      <if test="countryCode != null">
        country_code = #{countryCode,jdbcType=VARCHAR},
      </if>
      <if test="country != null">
        country = #{country,jdbcType=VARCHAR},
      </if>
      <if test="areaCode != null">
        area_code = #{areaCode,jdbcType=VARCHAR},
      </if>
      <if test="area != null">
        area = #{area,jdbcType=VARCHAR},
      </if>
      <if test="detailedAddress != null">
        detailed_address = #{detailedAddress,jdbcType=VARCHAR},
      </if>
      <if test="addressType != null">
        address_type = #{addressType,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserid != null">
        update_userid = #{updateUserid,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="priority != null">
        priority = #{priority,jdbcType=INTEGER},
      </if>
    </set>
    where address_id = #{addressId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.address.persistent.domain.UserCargoAddress">
    update user_cargo_address
    set tag = #{tag,jdbcType=VARCHAR},
      user_id = #{userId,jdbcType=INTEGER},
      contacts = #{contacts,jdbcType=VARCHAR},
      contact_phone = #{contactPhone,jdbcType=VARCHAR},
      province_code = #{provinceCode,jdbcType=VARCHAR},
      province = #{province,jdbcType=VARCHAR},
      city_code = #{cityCode,jdbcType=VARCHAR},
      city = #{city,jdbcType=VARCHAR},
      country_code = #{countryCode,jdbcType=VARCHAR},
      country = #{country,jdbcType=VARCHAR},
      area_code = #{areaCode,jdbcType=VARCHAR},
      area = #{area,jdbcType=VARCHAR},
      detailed_address = #{detailedAddress,jdbcType=VARCHAR},
      address_type = #{addressType,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_userid = #{updateUserid,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      priority = #{priority,jdbcType=INTEGER}
    where address_id = #{addressId,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into user_cargo_address  (tag, user_id, contacts, 
        contact_phone, province_code, province, 
        city_code, city, country_code, 
        country, area_code, area, 
        detailed_address, address_type, update_time, 
        update_userid, create_time, priority
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.tag,jdbcType=VARCHAR}, #{item.userId,jdbcType=INTEGER}, #{item.contacts,jdbcType=VARCHAR}, 
        #{item.contactPhone,jdbcType=VARCHAR}, #{item.provinceCode,jdbcType=VARCHAR}, #{item.province,jdbcType=VARCHAR}, 
        #{item.cityCode,jdbcType=VARCHAR}, #{item.city,jdbcType=VARCHAR}, #{item.countryCode,jdbcType=VARCHAR}, 
        #{item.country,jdbcType=VARCHAR}, #{item.areaCode,jdbcType=VARCHAR}, #{item.area,jdbcType=VARCHAR}, 
        #{item.detailedAddress,jdbcType=VARCHAR}, #{item.addressType,jdbcType=INTEGER}, #{item.updateTime,jdbcType=TIMESTAMP}, 
        #{item.updateUserid,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.priority,jdbcType=INTEGER}
        )
      </foreach>
    </if>
  </insert>
</mapper>