|
|
@@ -0,0 +1,273 @@
|
|
|
+<?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.dk.mdm.mapper.mst.CustomerMapper">
|
|
|
+
|
|
|
+ <!-- 通用设置 -->
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ cus_id, cus_code, cus_name, cus_phone, address_area, address_name, address_no, address_gcj02, address_full, contact_name, contact_phone, cus_from, channel_id, org_id, staff_id, report_staff, report_time, sale_status, remarks, follow_staffs, last_follow_staff, last_follow_id, last_follow_status, last_follow_time, follow_count, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
+ <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.Customer">
|
|
|
+ <id column="cus_id" property="cusId"/>
|
|
|
+ <result column="cus_code" property="cusCode"/>
|
|
|
+ <result column="cus_name" property="cusName"/>
|
|
|
+ <result column="cus_phone" property="cusPhone"/>
|
|
|
+ <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
|
|
|
+ <result column="address_name" property="addressName"/>
|
|
|
+ <result column="address_no" property="addressNo"/>
|
|
|
+ <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
|
|
|
+ <result column="address_full" property="addressFull"/>
|
|
|
+ <result column="contact_name" property="contactName"/>
|
|
|
+ <result column="contact_phone" property="contactPhone"/>
|
|
|
+ <result column="cus_from" property="cusFrom" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="channel_id" property="channelId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="report_staff" property="reportStaff" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="report_time" property="reportTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="sale_status" property="saleStatus"/>
|
|
|
+ <result column="remarks" property="remarks"/>
|
|
|
+ <result column="follow_staffs" property="followStaffs" typeHandler="UuidListTypeHandler"/>
|
|
|
+ <result column="last_follow_staff" property="lastFollowStaff" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="last_follow_id" property="lastFollowId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="last_follow_status" property="lastFollowStatus"/>
|
|
|
+ <result column="last_follow_time" property="lastFollowTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="follow_count" property="followCount"/>
|
|
|
+ <result column="flg_valid" property="flgValid"/>
|
|
|
+ <result column="cp_id" property="cpId"/>
|
|
|
+ <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="op_app_code" property="opAppCode"/>
|
|
|
+ <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_db_user" property="opDbUser"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition">
|
|
|
+ <where>
|
|
|
+ <if test="cusCode != null and cusCode != ''">
|
|
|
+ AND cus_code = #{cusCode}
|
|
|
+ </if>
|
|
|
+ <if test="cusName != null and cusName != ''">
|
|
|
+ AND cus_name = #{cusName}
|
|
|
+ </if>
|
|
|
+ <if test="cusPhone != null and cusPhone != ''">
|
|
|
+ AND cus_phone = #{cusPhone}
|
|
|
+ </if>
|
|
|
+ <if test="addressArea != null and addressArea != ''">
|
|
|
+ AND address_area = #{addressArea}
|
|
|
+ </if>
|
|
|
+ <if test="addressName != null and addressName != ''">
|
|
|
+ AND address_name = #{addressName}
|
|
|
+ </if>
|
|
|
+ <if test="addressNo != null and addressNo != ''">
|
|
|
+ AND address_no = #{addressNo}
|
|
|
+ </if>
|
|
|
+ <if test="addressGcj02 != null and addressGcj02 != ''">
|
|
|
+ AND address_gcj02 = #{addressGcj02}
|
|
|
+ </if>
|
|
|
+ <if test="addressFull != null and addressFull != ''">
|
|
|
+ AND address_full = #{addressFull}
|
|
|
+ </if>
|
|
|
+ <if test="contactName != null and contactName != ''">
|
|
|
+ AND contact_name = #{contactName}
|
|
|
+ </if>
|
|
|
+ <if test="contactPhone != null and contactPhone != ''">
|
|
|
+ AND contact_phone = #{contactPhone}
|
|
|
+ </if>
|
|
|
+ <if test="cusFrom != null and cusFrom != ''">
|
|
|
+ AND cus_from = #{cusFrom}
|
|
|
+ </if>
|
|
|
+ <if test="channelId != null and channelId != ''">
|
|
|
+ AND channel_id = #{channelId}
|
|
|
+ </if>
|
|
|
+ <if test="orgId != null and orgId != ''">
|
|
|
+ AND org_id = #{orgId}
|
|
|
+ </if>
|
|
|
+ <if test="staffId != null and staffId != ''">
|
|
|
+ AND staff_id = #{staffId}
|
|
|
+ </if>
|
|
|
+ <if test="reportStaff != null and reportStaff != ''">
|
|
|
+ AND report_staff = #{reportStaff}
|
|
|
+ </if>
|
|
|
+ <if test="reportTime != null">
|
|
|
+ AND report_time = #{reportTime}
|
|
|
+ </if>
|
|
|
+ <if test="saleStatus != null and saleStatus != ''">
|
|
|
+ AND sale_status = #{saleStatus}
|
|
|
+ </if>
|
|
|
+ <if test="remarks != null and remarks != ''">
|
|
|
+ AND remarks = #{remarks}
|
|
|
+ </if>
|
|
|
+ <if test="followStaffs != null and followStaffs != ''">
|
|
|
+ AND follow_staffs = #{followStaffs}
|
|
|
+ </if>
|
|
|
+ <if test="lastFollowStaff != null and lastFollowStaff != ''">
|
|
|
+ AND last_follow_staff = #{lastFollowStaff}
|
|
|
+ </if>
|
|
|
+ <if test="lastFollowId != null and lastFollowId != ''">
|
|
|
+ AND last_follow_id = #{lastFollowId}
|
|
|
+ </if>
|
|
|
+ <if test="lastFollowStatus != null and lastFollowStatus != ''">
|
|
|
+ AND last_follow_status = #{lastFollowStatus}
|
|
|
+ </if>
|
|
|
+ <if test="lastFollowTime != null">
|
|
|
+ AND last_follow_time = #{lastFollowTime}
|
|
|
+ </if>
|
|
|
+ <if test="followCount != null">
|
|
|
+ AND follow_count = #{followCount}
|
|
|
+ </if>
|
|
|
+ <if test="flgValid != null">
|
|
|
+ AND flg_valid = #{flgValid}
|
|
|
+ </if>
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateTime != null">
|
|
|
+ AND op_create_time = #{opCreateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateUserId != null and opCreateUserId != ''">
|
|
|
+ AND op_create_user_id = #{opCreateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateTime != null">
|
|
|
+ AND op_update_time = #{opUpdateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateUserId != null and opUpdateUserId != ''">
|
|
|
+ AND op_update_user_id = #{opUpdateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opAppCode != null and opAppCode != ''">
|
|
|
+ AND op_app_code = #{opAppCode}
|
|
|
+ </if>
|
|
|
+ <if test="opTimestamp != null">
|
|
|
+ AND op_timestamp = #{opTimestamp}
|
|
|
+ </if>
|
|
|
+ <if test="opDbUser != null and opDbUser != ''">
|
|
|
+ AND op_db_user = #{opDbUser}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="idsForeach">
|
|
|
+ <!-- 根据主键cusId批量操作 -->
|
|
|
+ WHERE cus_id in
|
|
|
+ <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 查询表t_mst_customer,(条件查询+分页)列表 -->
|
|
|
+ <select id="selectByCond" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_mst_customer
|
|
|
+ <include refid="Condition"/>
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表t_mst_customer,(条件查询)个数 -->
|
|
|
+ <select id="countByCond" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM t_mst_customer
|
|
|
+ <include refid="Condition"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键查询表t_mst_customer的一行数据 -->
|
|
|
+ <select id="selectById" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_mst_customer
|
|
|
+ WHERE cus_id = #{cusId}::uuid
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表t_mst_customer的一行数据 -->
|
|
|
+ <select id="selectByIdForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_mst_customer
|
|
|
+ WHERE cus_id = #{cusId}
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表t_mst_customer的多行数据 -->
|
|
|
+ <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_mst_customer
|
|
|
+ <include refid="idsForeach"/>
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into t_mst_customer
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ cus_code,
|
|
|
+ cus_name,
|
|
|
+ cus_phone,
|
|
|
+ address_area,
|
|
|
+ address_name,
|
|
|
+ address_no,
|
|
|
+ address_gcj02,
|
|
|
+ address_full,
|
|
|
+ contact_name,
|
|
|
+ contact_phone,
|
|
|
+ cus_from,
|
|
|
+ channel_id,
|
|
|
+ org_id,
|
|
|
+ staff_id,
|
|
|
+ report_staff,
|
|
|
+ report_time,
|
|
|
+ sale_status,
|
|
|
+ remarks,
|
|
|
+ follow_staffs,
|
|
|
+ last_follow_staff,
|
|
|
+ last_follow_id,
|
|
|
+ last_follow_status,
|
|
|
+ last_follow_time,
|
|
|
+ follow_count,
|
|
|
+ cp_id,
|
|
|
+ op_app_code,
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ <foreach collection="list" index="index" item="item" separator=",">
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ #{item.cusCode},
|
|
|
+ #{item.cusName},
|
|
|
+ #{item.cusPhone},
|
|
|
+ #{item.addressArea},
|
|
|
+ #{item.addressName},
|
|
|
+ #{item.addressNo},
|
|
|
+ #{item.addressGcj02},
|
|
|
+ #{item.addressFull},
|
|
|
+ #{item.contactName},
|
|
|
+ #{item.contactPhone},
|
|
|
+ #{item.cusFrom}::uuid,
|
|
|
+ #{item.channelId}::uuid,
|
|
|
+ #{item.orgId}::uuid,
|
|
|
+ #{item.staffId}::uuid,
|
|
|
+ #{item.reportStaff}::uuid,
|
|
|
+ #{item.reportTime},
|
|
|
+ #{item.saleStatus},
|
|
|
+ #{item.remarks},
|
|
|
+ #{item.followStaffs},
|
|
|
+ #{item.lastFollowStaff}::uuid,
|
|
|
+ #{item.lastFollowId}::uuid,
|
|
|
+ #{item.lastFollowStatus},
|
|
|
+ #{item.lastFollowTime},
|
|
|
+ #{item.followCount},
|
|
|
+ #{item.cpId},
|
|
|
+ #{item.opAppCode},
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+</mapper>
|