|
|
|
<?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.epmet.dao.UserWechatDao">
|
|
|
|
|
|
|
|
<!-- 根据userId更新 用户-微信关系表里的属性 -->
|
|
|
|
<update id="updateByUserId" parameterType="com.epmet.dto.UserWechatDTO">
|
|
|
|
UPDATE user_wechat
|
|
|
|
<set>
|
|
|
|
<if test='null != city and "" != city '>
|
|
|
|
CITY = #{city},
|
|
|
|
</if>
|
|
|
|
<if test='null != wxOpenId and "" != wxOpenId'>
|
|
|
|
WX_OPEN_ID = #{wxOpenId},
|
|
|
|
</if>
|
|
|
|
<if test='null != unionId and "" != unionId'>
|
|
|
|
WX_UNION_ID = #{unionId},
|
|
|
|
</if>
|
|
|
|
<if test='null != nickname and "" != nickname '>
|
|
|
|
NICKNAME = #{nickname},
|
|
|
|
</if>
|
|
|
|
<if test='null != country and "" != country '>
|
|
|
|
COUNTRY = #{country},
|
|
|
|
</if>
|
|
|
|
<if test='null != headImgUrl and "" != headImgUrl'>
|
|
|
|
HEAD_IMG_URL = #{headImgUrl},
|
|
|
|
</if>
|
|
|
|
<if test='null != province and "" != province '>
|
|
|
|
PROVINCE = #{province},
|
|
|
|
</if>
|
|
|
|
<if test='null != sex'>
|
|
|
|
SEX = #{sex},
|
|
|
|
</if>
|
|
|
|
UPDATED_BY = #{updatedBy},
|
|
|
|
UPDATED_TIME = #{updatedTime}
|
|
|
|
</set>
|
|
|
|
WHERE
|
|
|
|
USER_ID = #{userId}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 根据app、openId查询用户是否存在 -->
|
|
|
|
<select id="selectUserDTOByOpenId" parameterType="com.epmet.dto.form.WxLoginUserInfoFormDTO" resultType="com.epmet.dto.UserDTO">
|
|
|
|
SELECT
|
|
|
|
u.*
|
|
|
|
FROM
|
|
|
|
USER u
|
|
|
|
LEFT JOIN user_wechat uw ON (
|
|
|
|
u.id = uw.USER_ID
|
|
|
|
AND uw.WX_OPEN_ID = #{openId})
|
|
|
|
WHERE
|
|
|
|
u.DEL_FLAG = '0'
|
|
|
|
AND uw.DEL_FLAG = '0'
|
|
|
|
AND u.FROM_APP = #{app}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectByUserId" parameterType="string" resultType="com.epmet.entity.UserWechatEntity">
|
|
|
|
SELECT *
|
|
|
|
|
|
|
|
FROM
|
|
|
|
USER_WECHAT
|
|
|
|
WHERE
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
AND
|
|
|
|
USER_ID = #{userId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 根据userId查询头像 -->
|
|
|
|
<select id="selectUserHeadPhotoByUserId" resultType="com.epmet.dto.UserHeadPhotoDTO">
|
|
|
|
SELECT
|
|
|
|
user_id AS userId,
|
|
|
|
IFNULL(head_img_url,'') AS userHeadPhoto
|
|
|
|
FROM
|
|
|
|
user_wechat
|
|
|
|
WHERE
|
|
|
|
user_id in
|
|
|
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
|
|
|
#{item.userId}
|
|
|
|
</foreach>
|
|
|
|
AND del_flag = 0
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 查询已经授权的微信用户信息 -->
|
|
|
|
<select id="selectAll" resultType="com.epmet.dto.UserWechatDTO">
|
|
|
|
SELECT
|
|
|
|
*
|
|
|
|
FROM
|
|
|
|
user_wechat uw
|
|
|
|
WHERE
|
|
|
|
uw.DEL_FLAG = '0'
|
|
|
|
AND uw.NICKNAME IS NOT NULL
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 查询人员信息,排序,包括陌生人与注册居民,没有注册居民则只有微信昵称 -->
|
|
|
|
<select id="selectResiAndStrangerInfo" resultType="com.epmet.dto.result.CustomerUser4PointResultDTO">
|
|
|
|
SELECT
|
|
|
|
wechat.USER_ID,
|
|
|
|
IFNULL(wechat.NICKNAME,'') AS userNickname,
|
|
|
|
IFNULL(wechat.HEAD_IMG_URL,'') AS userHeadPhoto,
|
|
|
|
IFNULL(base.REAL_NAME,'') AS userName
|
|
|
|
FROM
|
|
|
|
user_wechat wechat
|
|
|
|
LEFT JOIN
|
|
|
|
user_base_info base on wechat.USER_ID = base.USER_ID
|
|
|
|
WHERE
|
|
|
|
wechat.DEL_FLAG = '0'
|
|
|
|
AND (wechat.NICKNAME IS NOT NULL OR wechat.NICKNAME <![CDATA[ <> ]]> '')
|
|
|
|
<foreach collection="userIds" item="item" open="AND (" separator=" OR " close=" )">
|
|
|
|
wechat.USER_ID = #{item}
|
|
|
|
</foreach>
|
|
|
|
<if test='null != realName and "" != realName'>
|
|
|
|
AND (base.REAL_NAME LIKE concat('%',#{realName},'%') OR wechat.NICKNAME LIKE concat('%',#{realName},'%'))
|
|
|
|
</if>
|
|
|
|
ORDER BY
|
|
|
|
base.REAL_NAME , wechat.NICKNAME
|
|
|
|
</select>
|
|
|
|
</mapper>
|