2021-04-08 22:53:25 +08:00
|
|
|
<?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">
|
2021-04-29 11:16:42 +08:00
|
|
|
<mapper namespace="ink.wgink.module.wechat.dao.miniapp.IMiniAppUserDao">
|
2021-04-08 22:53:25 +08:00
|
|
|
|
|
|
|
<cache flushInterval="3600000"/>
|
|
|
|
|
2021-08-02 23:02:17 +08:00
|
|
|
<resultMap id="miniappUserPO" type="ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO">
|
2021-04-08 22:53:25 +08:00
|
|
|
<result column="app_id" property="appId"/>
|
|
|
|
<result column="open_id" property="openId"/>
|
|
|
|
<result column="user_id" property="userId"/>
|
|
|
|
<result column="is_init_account" property="isInitAccount"/>
|
|
|
|
<result column="gmt_create" property="gmtCreate"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 建表 -->
|
|
|
|
<update id="createTable">
|
2021-04-09 20:19:31 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS `wechat_mini_app_user` (
|
2021-04-08 22:53:25 +08:00
|
|
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`app_id` varchar(255) DEFAULT NULL COMMENT 'appid',
|
|
|
|
`open_id` varchar(255) DEFAULT NULL COMMENT 'openid',
|
|
|
|
`user_id` varchar(255) DEFAULT NULL COMMENT '用户ID',
|
2021-08-02 23:02:17 +08:00
|
|
|
`nick_name` varchar(255) DEFAULT NULL COMMENT '微信昵称',
|
|
|
|
`avatar_url` varchar(500) DEFAULT NULL COMMENT '微信头像',
|
2021-04-08 22:53:25 +08:00
|
|
|
`is_init_account` int(1) DEFAULT '0' COMMENT '是否初始化账户',
|
|
|
|
`gmt_create` datetime DEFAULT NULL,
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `app_id` (`app_id`) USING BTREE,
|
|
|
|
KEY `open_id` (`open_id`) USING BTREE,
|
|
|
|
KEY `user_id` (`user_id`) USING BTREE
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='小程序用户';
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 保存 -->
|
2021-08-03 10:58:12 +08:00
|
|
|
<insert id="save" parameterType="map" flushCache="true">
|
2021-04-08 22:53:25 +08:00
|
|
|
INSERT INTO wechat_mini_app_user(
|
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
|
|
|
is_init_account,
|
|
|
|
gmt_create
|
|
|
|
) VALUES(
|
|
|
|
#{appId},
|
|
|
|
#{openId},
|
|
|
|
#{userId},
|
|
|
|
#{isInitAccount},
|
|
|
|
#{gmtCreate}
|
|
|
|
)
|
|
|
|
</insert>
|
|
|
|
|
2021-08-02 23:02:17 +08:00
|
|
|
<!-- 更新信息 -->
|
2021-08-03 10:58:12 +08:00
|
|
|
<update id="updateInfo" parameterType="map" flushCache="true">
|
2021-08-02 23:02:17 +08:00
|
|
|
UPDATE
|
|
|
|
wechat_mini_app_user
|
|
|
|
SET
|
|
|
|
nick_name = #{nickName},
|
|
|
|
avatar_url = #{avatarUrl}
|
|
|
|
WHERE
|
|
|
|
<if test="userId != null and userId != ''">
|
|
|
|
user_id = #{userId}
|
|
|
|
</if>
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 更新是否初始化账号 -->
|
2021-08-03 10:58:12 +08:00
|
|
|
<update id="updateIsInitAccount" parameterType="map" flushCache="true">
|
2021-08-02 23:02:17 +08:00
|
|
|
UPDATE
|
|
|
|
wechat_mini_app_user
|
|
|
|
SET
|
|
|
|
is_init_account = #{isInitAccount}
|
|
|
|
WHERE
|
|
|
|
<if test="userId != null and userId != ''">
|
|
|
|
user_id = #{userId}
|
|
|
|
</if>
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
<select id="listPO" parameterType="map" resultMap="miniappUserPO" useCache="true">
|
|
|
|
SELECT
|
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
|
|
|
nick_name,
|
|
|
|
avatar_url,
|
|
|
|
is_init_account,
|
|
|
|
gmt_create
|
|
|
|
FROM
|
|
|
|
wechat_mini_app_user
|
|
|
|
<where>
|
|
|
|
<if test="userIds != null and userIds.size > 0">
|
|
|
|
user_id IN
|
|
|
|
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{userIds[${index}]}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
2021-04-08 22:53:25 +08:00
|
|
|
<!-- 详情 -->
|
2021-08-02 23:02:17 +08:00
|
|
|
<select id="getPO" parameterType="map" resultMap="miniappUserPO" useCache="true">
|
2021-04-08 22:53:25 +08:00
|
|
|
SELECT
|
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
2021-08-02 23:02:17 +08:00
|
|
|
nick_name,
|
|
|
|
avatar_url,
|
2021-04-08 22:53:25 +08:00
|
|
|
is_init_account,
|
|
|
|
gmt_create
|
|
|
|
FROM
|
|
|
|
wechat_mini_app_user
|
|
|
|
<where>
|
|
|
|
<if test="appId != null and appId != ''">
|
|
|
|
app_id = #{appId}
|
|
|
|
</if>
|
2021-08-03 10:58:12 +08:00
|
|
|
<if test="openId != null and openId != ''">
|
2021-04-08 22:53:25 +08:00
|
|
|
AND
|
|
|
|
open_id = #{openId}
|
|
|
|
</if>
|
|
|
|
<if test="userId != null and userId != ''">
|
|
|
|
AND
|
|
|
|
user_id = #{userId}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
</mapper>
|