<?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.xmomen.module.member.entity.mapper.MemberAddressMapper" >
  <resultMap id="BaseResultMap" type="com.xmomen.module.member.entity.MemberAddress" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="cd_member_id" property="cdMemberId" jdbcType="INTEGER" />
    <result column="province" property="province" jdbcType="INTEGER" />
    <result column="city" property="city" jdbcType="INTEGER" />
    <result column="area" property="area" jdbcType="INTEGER" />
    <result column="address" property="address" jdbcType="VARCHAR" />
    <result column="full_address" property="fullAddress" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="mobile" property="mobile" jdbcType="VARCHAR" />
    <result column="is_default" property="isDefault" jdbcType="CHAR" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" 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="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    id, cd_member_id, province, city, area, address, full_address, name, mobile, is_default
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.xmomen.module.member.entity.MemberAddressExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cd_member_address
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <delete id="deleteByExample" parameterType="com.xmomen.module.member.entity.MemberAddressExample" >
    delete from cd_member_address
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.xmomen.module.member.entity.MemberAddress" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
    <selectKey resultType="java.lang.String" keyProperty="id" order="BEFORE" >
      SELECT replace(UUID(),'-','')
    </selectKey>
    insert into cd_member_address
    <trim prefix="(" suffix=")" suffixOverrides="," >
      id,
      <if test="cdMemberId != null" >
        cd_member_id,
      </if>
      <if test="province != null" >
        province,
      </if>
      <if test="city != null" >
        city,
      </if>
      <if test="area != null" >
        area,
      </if>
      <if test="address != null" >
        address,
      </if>
      <if test="fullAddress != null" >
        full_address,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="mobile != null" >
        mobile,
      </if>
      <if test="isDefault != null" >
        is_default,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      #{id,jdbcType=VARCHAR},
      <if test="cdMemberId != null" >
        #{cdMemberId,jdbcType=INTEGER},
      </if>
      <if test="province != null" >
        #{province,jdbcType=INTEGER},
      </if>
      <if test="city != null" >
        #{city,jdbcType=INTEGER},
      </if>
      <if test="area != null" >
        #{area,jdbcType=INTEGER},
      </if>
      <if test="address != null" >
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="fullAddress != null" >
        #{fullAddress,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="mobile != null" >
        #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="isDefault != null" >
        #{isDefault,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.xmomen.module.member.entity.MemberAddressExample" resultType="java.lang.Integer" >
    select count(*) from cd_member_address
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cd_member_address
    <set >
      <if test="record.id != null" >
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.cdMemberId != null" >
        cd_member_id = #{record.cdMemberId,jdbcType=INTEGER},
      </if>
      <if test="record.province != null" >
        province = #{record.province,jdbcType=INTEGER},
      </if>
      <if test="record.city != null" >
        city = #{record.city,jdbcType=INTEGER},
      </if>
      <if test="record.area != null" >
        area = #{record.area,jdbcType=INTEGER},
      </if>
      <if test="record.address != null" >
        address = #{record.address,jdbcType=VARCHAR},
      </if>
      <if test="record.fullAddress != null" >
        full_address = #{record.fullAddress,jdbcType=VARCHAR},
      </if>
      <if test="record.name != null" >
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.mobile != null" >
        mobile = #{record.mobile,jdbcType=VARCHAR},
      </if>
      <if test="record.isDefault != null" >
        is_default = #{record.isDefault,jdbcType=CHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>