|
|
@@ -0,0 +1,189 @@
|
|
|
+<?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.WxUserMapper">
|
|
|
+
|
|
|
+ <!-- 通用设置 -->
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ user_id, user_wxid, user_name, user_phone, user_pwd, current_cp, joined_cps, flg_valid, remarks, 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.WxUser">
|
|
|
+ <id column="user_id" property="userId"/>
|
|
|
+ <result column="user_wxid" property="userWxid"/>
|
|
|
+ <result column="user_name" property="userName"/>
|
|
|
+ <result column="user_phone" property="userPhone"/>
|
|
|
+ <result column="user_pwd" property="userPwd"/>
|
|
|
+ <result column="current_cp" property="currentCp"/>
|
|
|
+ <result column="joined_cps" property="joinedCps" typeHandler="IntListTypeHandler"/>
|
|
|
+ <result column="flg_valid" property="flgValid"/>
|
|
|
+ <result column="remarks" property="remarks"/>
|
|
|
+ <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_create_user_id" property="opCreateUserId"/>
|
|
|
+ <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_update_user_id" property="opUpdateUserId"/>
|
|
|
+ <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="userWxid != null and userWxid != ''">
|
|
|
+ AND user_wxid = #{userWxid}
|
|
|
+ </if>
|
|
|
+ <if test="userName != null and userName != ''">
|
|
|
+ AND user_name = #{userName}
|
|
|
+ </if>
|
|
|
+ <if test="userPhone != null and userPhone != ''">
|
|
|
+ AND user_phone = #{userPhone}
|
|
|
+ </if>
|
|
|
+ <if test="userPwd != null and userPwd != ''">
|
|
|
+ AND user_pwd = #{userPwd}
|
|
|
+ </if>
|
|
|
+ <if test="currentCp != null">
|
|
|
+ AND current_cp = #{currentCp}
|
|
|
+ </if>
|
|
|
+ <if test="joinedCps != null">
|
|
|
+ AND joined_cps = #{joinedCps}
|
|
|
+ </if>
|
|
|
+ <if test="flgValid != null">
|
|
|
+ AND flg_valid = #{flgValid}
|
|
|
+ </if>
|
|
|
+ <if test="remarks != null and remarks != ''">
|
|
|
+ AND remarks = #{remarks}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateTime != null">
|
|
|
+ AND op_create_time = #{opCreateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateUserId != null">
|
|
|
+ AND op_create_user_id = #{opCreateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateTime != null">
|
|
|
+ AND op_update_time = #{opUpdateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateUserId != null">
|
|
|
+ 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">
|
|
|
+ <!-- 根据主键userId批量操作 -->
|
|
|
+ WHERE user_id in
|
|
|
+ <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 查询表t_wx_user,(条件查询+分页)列表 -->
|
|
|
+ <select id="selectByCond" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_wx_user
|
|
|
+ <include refid="Condition"/>
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表t_wx_user,(条件查询)个数 -->
|
|
|
+ <select id="countByCond" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM t_wx_user
|
|
|
+ <include refid="Condition"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键查询表t_wx_user的一行数据 -->
|
|
|
+ <select id="selectById" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_wx_user
|
|
|
+ WHERE user_id = #{userId}::uuid
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表t_wx_user的一行数据 -->
|
|
|
+ <select id="selectByIdForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_wx_user
|
|
|
+ WHERE user_id = #{userId}
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表t_wx_user的多行数据 -->
|
|
|
+ <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_wx_user
|
|
|
+ <include refid="idsForeach"/>
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into t_wx_user
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ user_wxid,
|
|
|
+ user_name,
|
|
|
+ user_phone,
|
|
|
+ user_pwd,
|
|
|
+ current_cp,
|
|
|
+ joined_cps,
|
|
|
+ remarks,
|
|
|
+ op_app_code,
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ <foreach collection="list" index="index" item="item" separator=",">
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ #{item.userWxid},
|
|
|
+ #{item.userName},
|
|
|
+ #{item.userPhone},
|
|
|
+ #{item.userPwd},
|
|
|
+ #{item.currentCp},
|
|
|
+ #{item.joinedCps},
|
|
|
+ #{item.remarks},
|
|
|
+ #{item.opAppCode},
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 根据电话号码获取用户信息 -->
|
|
|
+ <select id="getByPhone" resultMap="BaseResultMap">
|
|
|
+ SELECT txu.user_id,
|
|
|
+ txu.user_wxid,
|
|
|
+ txu.user_name,
|
|
|
+ txu.user_phone,
|
|
|
+ txu.user_pwd,
|
|
|
+ txu.current_cp,
|
|
|
+ txu.flg_valid,
|
|
|
+ txu.joined_cps
|
|
|
+ FROM dkic_a.t_wx_user txu
|
|
|
+ where txu.user_phone = #{userPhone}
|
|
|
+ AND txu.flg_valid
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--更新微信用的公司-->
|
|
|
+ <update id="updateCpid">
|
|
|
+ update dkic_a.t_wx_user set current_cp = #{currentCp}
|
|
|
+ <if test="joinedCps != null">
|
|
|
+ ,joined_cps = #{joinedCps,typeHandler=IntListTypeHandler}
|
|
|
+ </if>
|
|
|
+ where user_id = #{userId}::uuid
|
|
|
+ </update>
|
|
|
+</mapper>
|