2021-04-28 21:18:00 +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-28 23:01:14 +08:00
|
|
|
<mapper namespace="ink.wgink.module.wechat.dao.official.account.IOfficialAccountUserDao">
|
2021-04-28 21:18:00 +08:00
|
|
|
|
|
|
|
<cache flushInterval="3600000"/>
|
|
|
|
|
2021-04-28 23:01:14 +08:00
|
|
|
<resultMap id="officialAccountUserPO" type="ink.wgink.module.wechat.pojo.pos.official.account.OfficialAccountUserPO">
|
2021-04-28 21:18:00 +08:00
|
|
|
<result column="app_id" property="appId"/>
|
|
|
|
<result column="open_id" property="openId"/>
|
|
|
|
<result column="user_id" property="userId"/>
|
2021-05-02 12:22:30 +08:00
|
|
|
<result column="user_code" property="userCode"/>
|
2021-04-28 21:18:00 +08:00
|
|
|
<result column="is_init_account" property="isInitAccount"/>
|
|
|
|
<result column="gmt_create" property="gmtCreate"/>
|
2021-04-28 23:01:14 +08:00
|
|
|
<result column="gmt_modified" property="gmtModified"/>
|
|
|
|
<result column="status" property="status"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<resultMap id="officialAccountUserDTO" type="ink.wgink.module.wechat.pojo.dtos.official.account.OfficialAccountUserDTO">
|
|
|
|
<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"/>
|
|
|
|
<result column="status" property="status"/>
|
2021-04-28 21:18:00 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 建表 -->
|
|
|
|
<update id="createTable">
|
2021-04-28 23:01:14 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS `wechat_official_account_user` (
|
2021-04-28 21:18:00 +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-04-28 23:01:14 +08:00
|
|
|
`user_code` varchar(255) DEFAULT NULL COMMENT '用户码',
|
|
|
|
`status` varchar(255) DEFAULT NULL COMMENT '订阅状态',
|
2021-04-28 21:18:00 +08:00
|
|
|
`is_init_account` int(1) DEFAULT '0' COMMENT '是否初始化账户',
|
|
|
|
`gmt_create` datetime DEFAULT NULL,
|
2021-04-28 23:01:14 +08:00
|
|
|
`gmt_modified` datetime DEFAULT NULL,
|
2021-04-28 21:18:00 +08:00
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `app_id` (`app_id`) USING BTREE,
|
|
|
|
KEY `open_id` (`open_id`) USING BTREE,
|
2021-08-18 15:28:19 +08:00
|
|
|
KEY `user_id` (`user_id`) USING BTREE,
|
|
|
|
KEY `user_code` (`user_code`) USING BTREE,
|
2021-04-28 21:18:00 +08:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='小程序用户';
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 保存 -->
|
2021-05-02 12:22:30 +08:00
|
|
|
<insert id="save" parameterType="map" flushCache="true" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
2021-04-28 23:01:14 +08:00
|
|
|
INSERT INTO wechat_official_account_user(
|
2021-04-28 21:18:00 +08:00
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
2021-04-28 23:01:14 +08:00
|
|
|
user_code,
|
|
|
|
status,
|
2021-04-28 21:18:00 +08:00
|
|
|
is_init_account,
|
2021-04-28 23:01:14 +08:00
|
|
|
gmt_create,
|
|
|
|
gmt_modified
|
2021-04-28 21:18:00 +08:00
|
|
|
) VALUES(
|
|
|
|
#{appId},
|
|
|
|
#{openId},
|
|
|
|
#{userId},
|
2021-04-28 23:01:14 +08:00
|
|
|
#{userCode},
|
|
|
|
#{status},
|
2021-04-28 21:18:00 +08:00
|
|
|
#{isInitAccount},
|
2021-04-28 23:01:14 +08:00
|
|
|
#{gmtCreate},
|
|
|
|
#{gmtModified}
|
2021-04-28 21:18:00 +08:00
|
|
|
)
|
|
|
|
</insert>
|
|
|
|
|
2021-04-28 23:01:14 +08:00
|
|
|
<!-- 删除 -->
|
2021-08-18 15:28:19 +08:00
|
|
|
<update id="delete" parameterType="map" flushCache="true">
|
2021-04-28 23:01:14 +08:00
|
|
|
DELETE FROM
|
|
|
|
wechat_official_account_user
|
|
|
|
WHERE
|
2021-08-18 15:28:19 +08:00
|
|
|
<if test="userIds != null and userIds.size > 0">
|
|
|
|
user_id IN
|
|
|
|
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{userIds[${index}]}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
2021-04-28 23:01:14 +08:00
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 修改 -->
|
|
|
|
<update id="update" parameterType="map" flushCache="true">
|
|
|
|
UPDATE
|
|
|
|
wechat_official_account_user
|
|
|
|
SET
|
|
|
|
<if test="userId != null">
|
|
|
|
user_id = #{userId},
|
|
|
|
</if>
|
|
|
|
<if test="status != null and status != ''">
|
|
|
|
status = #{status},
|
|
|
|
</if>
|
|
|
|
gmt_modified = #{gmtModified}
|
|
|
|
WHERE
|
|
|
|
app_id = #{appId}
|
|
|
|
AND
|
|
|
|
open_id = #{openId}
|
|
|
|
</update>
|
|
|
|
|
2021-05-02 12:22:30 +08:00
|
|
|
<!-- 修改用户码(邀请码) -->
|
|
|
|
<update id="updateUserCode" parameterType="map" flushCache="true">
|
|
|
|
UPDATE
|
|
|
|
wechat_official_account_user
|
|
|
|
SET
|
|
|
|
user_code = #{userCode}
|
|
|
|
WHERE
|
|
|
|
app_id = #{appId}
|
|
|
|
AND
|
|
|
|
open_id = #{openId}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
2021-05-02 16:20:31 +08:00
|
|
|
<!-- 修改用户码(邀请码) -->
|
|
|
|
<update id="updateIsInitAccount" parameterType="map" flushCache="true">
|
|
|
|
UPDATE
|
|
|
|
wechat_official_account_user
|
|
|
|
SET
|
|
|
|
is_init_account = #{isInitAccount}
|
|
|
|
WHERE
|
|
|
|
app_id = #{appId}
|
|
|
|
AND
|
|
|
|
open_id = #{openId}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-28 21:18:00 +08:00
|
|
|
<!-- 详情 -->
|
2021-04-28 23:01:14 +08:00
|
|
|
<select id="get" parameterType="map" resultMap="officialAccountUserDTO" useCache="true">
|
2021-04-28 21:18:00 +08:00
|
|
|
SELECT
|
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
2021-04-28 23:01:14 +08:00
|
|
|
status,
|
2021-04-28 21:18:00 +08:00
|
|
|
is_init_account,
|
2021-04-28 23:01:14 +08:00
|
|
|
LEFT(gmt_create, 19) gmt_create,
|
|
|
|
LEFT(gmt_modified, 19) gmt_modified
|
2021-04-28 21:18:00 +08:00
|
|
|
FROM
|
2021-04-28 23:01:14 +08:00
|
|
|
wechat_official_account_user
|
2021-04-28 21:18:00 +08:00
|
|
|
<where>
|
|
|
|
<if test="appId != null and appId != ''">
|
2021-04-28 23:01:14 +08:00
|
|
|
app_id = #{appId}
|
2021-04-28 21:18:00 +08:00
|
|
|
</if>
|
|
|
|
<if test="openId != '' and openId != ''">
|
|
|
|
AND
|
|
|
|
open_id = #{openId}
|
|
|
|
</if>
|
|
|
|
<if test="userId != null and userId != ''">
|
|
|
|
AND
|
|
|
|
user_id = #{userId}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
2021-04-28 23:01:14 +08:00
|
|
|
<!-- 详情 -->
|
|
|
|
<select id="list" parameterType="map" resultMap="officialAccountUserDTO" useCache="true">
|
|
|
|
SELECT
|
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
|
|
|
status,
|
|
|
|
is_init_account,
|
|
|
|
LEFT(gmt_create, 19) gmt_create,
|
|
|
|
LEFT(gmt_modified, 19) gmt_modified
|
|
|
|
FROM
|
|
|
|
wechat_official_account_user
|
|
|
|
<where>
|
|
|
|
<if test="status != null and status != ''">
|
|
|
|
status = #{status}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 详情 -->
|
|
|
|
<select id="getPO" parameterType="map" resultMap="officialAccountUserPO" useCache="true">
|
|
|
|
SELECT
|
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
2021-05-02 12:22:30 +08:00
|
|
|
user_code,
|
2021-04-28 23:01:14 +08:00
|
|
|
status,
|
|
|
|
is_init_account,
|
|
|
|
gmt_create,
|
|
|
|
gmt_modified
|
|
|
|
FROM
|
|
|
|
wechat_official_account_user
|
|
|
|
<where>
|
|
|
|
<if test="appId != null and appId != ''">
|
|
|
|
app_id = #{appId}
|
|
|
|
</if>
|
|
|
|
<if test="openId != '' and openId != ''">
|
|
|
|
AND
|
|
|
|
open_id = #{openId}
|
|
|
|
</if>
|
|
|
|
<if test="userId != null and userId != ''">
|
|
|
|
AND
|
|
|
|
user_id = #{userId}
|
|
|
|
</if>
|
2021-05-02 16:20:31 +08:00
|
|
|
<if test="userCode != null and userCode != ''">
|
|
|
|
AND
|
|
|
|
user_code = #{userCode}
|
|
|
|
</if>
|
2021-04-28 23:01:14 +08:00
|
|
|
</where>
|
|
|
|
</select>
|
2021-04-28 21:18:00 +08:00
|
|
|
|
2021-04-28 23:01:14 +08:00
|
|
|
<!-- 详情 -->
|
|
|
|
<select id="listPO" parameterType="map" resultMap="officialAccountUserPO" useCache="true">
|
|
|
|
SELECT
|
|
|
|
app_id,
|
|
|
|
open_id,
|
|
|
|
user_id,
|
2021-05-02 12:22:30 +08:00
|
|
|
user_code,
|
2021-04-28 23:01:14 +08:00
|
|
|
status,
|
|
|
|
is_init_account,
|
|
|
|
gmt_create,
|
|
|
|
gmt_modified
|
|
|
|
FROM
|
|
|
|
wechat_official_account_user
|
|
|
|
<where>
|
|
|
|
<if test="status != null and status != ''">
|
|
|
|
status = #{status}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
2021-04-28 21:18:00 +08:00
|
|
|
|
|
|
|
</mapper>
|