CustomerAddressMapper.xml 6.64 KB
<?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="cn.runsa.crmapp.customer.mapper.CustomerAddressMapper">
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.customer.entity.CustomerAddress">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="ADDR_ID" jdbcType="BIGINT" property="addrId" />
    <result column="CST_ID" jdbcType="BIGINT" property="cstId" />
    <result column="COUNTRY_CODE" jdbcType="INTEGER" property="countryCode" />
    <result column="PROVINCE_CODE" jdbcType="INTEGER" property="provinceCode" />
    <result column="CITY_CODE" jdbcType="INTEGER" property="cityCode" />
    <result column="COUNTY_CODE" jdbcType="INTEGER" property="countyCode" />
    <result column="DETAIL" jdbcType="VARCHAR" property="detail" />
    <result column="ZIP_CODE" jdbcType="VARCHAR" property="zipCode" />
    <result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    `ADDR_ID`, `CST_ID`, `COUNTRY_CODE`, `PROVINCE_CODE`, `CITY_CODE`, `COUNTY_CODE`, 
    `DETAIL`, `ZIP_CODE`, `REC_TIME`
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from crm_customer_address
    where `ADDR_ID` = #{addrId,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from crm_customer_address
    where `ADDR_ID` = #{addrId,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="cn.runsa.crmapp.customer.entity.CustomerAddress">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <selectKey keyProperty="addrId" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into crm_customer_address (`CST_ID`, `COUNTRY_CODE`, `PROVINCE_CODE`, 
      `CITY_CODE`, `COUNTY_CODE`, `DETAIL`, 
      `ZIP_CODE`, `REC_TIME`)
    values (#{cstId,jdbcType=BIGINT}, #{countryCode,jdbcType=INTEGER}, #{provinceCode,jdbcType=INTEGER}, 
      #{cityCode,jdbcType=INTEGER}, #{countyCode,jdbcType=INTEGER}, #{detail,jdbcType=VARCHAR}, 
      #{zipCode,jdbcType=VARCHAR}, #{recTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.crmapp.customer.entity.CustomerAddress">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <selectKey keyProperty="addrId" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into crm_customer_address
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="cstId != null">
        `CST_ID`,
      </if>
      <if test="countryCode != null">
        `COUNTRY_CODE`,
      </if>
      <if test="provinceCode != null">
        `PROVINCE_CODE`,
      </if>
      <if test="cityCode != null">
        `CITY_CODE`,
      </if>
      <if test="countyCode != null">
        `COUNTY_CODE`,
      </if>
      <if test="detail != null">
        `DETAIL`,
      </if>
      <if test="zipCode != null">
        `ZIP_CODE`,
      </if>
      <if test="recTime != null">
        `REC_TIME`,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="cstId != null">
        #{cstId,jdbcType=BIGINT},
      </if>
      <if test="countryCode != null">
        #{countryCode,jdbcType=INTEGER},
      </if>
      <if test="provinceCode != null">
        #{provinceCode,jdbcType=INTEGER},
      </if>
      <if test="cityCode != null">
        #{cityCode,jdbcType=INTEGER},
      </if>
      <if test="countyCode != null">
        #{countyCode,jdbcType=INTEGER},
      </if>
      <if test="detail != null">
        #{detail,jdbcType=VARCHAR},
      </if>
      <if test="zipCode != null">
        #{zipCode,jdbcType=VARCHAR},
      </if>
      <if test="recTime != null">
        #{recTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.customer.entity.CustomerAddress">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update crm_customer_address
    <set>
      <if test="cstId != null">
        `CST_ID` = #{cstId,jdbcType=BIGINT},
      </if>
      <if test="countryCode != null">
        `COUNTRY_CODE` = #{countryCode,jdbcType=INTEGER},
      </if>
      <if test="provinceCode != null">
        `PROVINCE_CODE` = #{provinceCode,jdbcType=INTEGER},
      </if>
      <if test="cityCode != null">
        `CITY_CODE` = #{cityCode,jdbcType=INTEGER},
      </if>
      <if test="countyCode != null">
        `COUNTY_CODE` = #{countyCode,jdbcType=INTEGER},
      </if>
      <if test="detail != null">
        `DETAIL` = #{detail,jdbcType=VARCHAR},
      </if>
      <if test="zipCode != null">
        `ZIP_CODE` = #{zipCode,jdbcType=VARCHAR},
      </if>
      <if test="recTime != null">
        `REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where `ADDR_ID` = #{addrId,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.customer.entity.CustomerAddress">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update crm_customer_address
    set `CST_ID` = #{cstId,jdbcType=BIGINT},
      `COUNTRY_CODE` = #{countryCode,jdbcType=INTEGER},
      `PROVINCE_CODE` = #{provinceCode,jdbcType=INTEGER},
      `CITY_CODE` = #{cityCode,jdbcType=INTEGER},
      `COUNTY_CODE` = #{countyCode,jdbcType=INTEGER},
      `DETAIL` = #{detail,jdbcType=VARCHAR},
      `ZIP_CODE` = #{zipCode,jdbcType=VARCHAR},
      `REC_TIME` = #{recTime,jdbcType=TIMESTAMP}
    where `ADDR_ID` = #{addrId,jdbcType=BIGINT}
  </update>
  
  <select id="SelectCustomerAddress" parameterType="java.lang.Long" resultType="map">
    select 
    a.DETAIL as detail ,CONCAT(b.last_name,b.first_name) as name,phone
    from crm_customer_address a,crm_customer b
    where 
    a.cst_id=b.cst_id
    and a.`CST_ID` = #{custId,jdbcType=BIGINT}
  </select>
</mapper>