新增微信 公众号与小程序 删除功能,用户删除添加关联用户信息删除
This commit is contained in:
parent
97e26d7736
commit
2beeb2b504
@ -0,0 +1,28 @@
|
||||
package ink.wgink.interfaces.user.wechat.miniapp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: IMiniappUserBaseService
|
||||
* @Description: 微信小程序接口
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/8/18 10:59 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IMiniappUserBaseService {
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
void delete(String userId);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param userIds 用户ID列表
|
||||
*/
|
||||
void delete(List<String> userIds);
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ink.wgink.interfaces.user.wechat.official.account;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: IOfficialAccountBaseService
|
||||
* @Description: 公众号用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/8/18 3:11 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IOfficialAccountBaseService {
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
void delete(String userId);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param userIds 用户ID列表
|
||||
*/
|
||||
void delete(List<String> userIds);
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package ink.wgink.module.wechat.dao.miniapp;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
@ -31,6 +32,14 @@ public interface IMiniAppUserDao extends IInitBaseTable {
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void delete(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 更新信息
|
||||
*
|
||||
@ -47,6 +56,14 @@ public interface IMiniAppUserDao extends IInitBaseTable {
|
||||
*/
|
||||
void updateIsInitAccount(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 更新用户码
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateUserCode(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
|
@ -33,6 +33,14 @@ public interface IOfficialAccountUserDao extends IInitBaseTable {
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void delete(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
@ -51,19 +59,12 @@ public interface IOfficialAccountUserDao extends IInitBaseTable {
|
||||
|
||||
/**
|
||||
* 修改初始账号标识
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateIsInitAccount(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void remove(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
@ -100,5 +101,4 @@ public interface IOfficialAccountUserDao extends IInitBaseTable {
|
||||
*/
|
||||
List<OfficialAccountUserPO> listPO(Map<String, Object> params) throws SearchException;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ink.wgink.module.wechat.service.miniapp;
|
||||
|
||||
|
||||
import ink.wgink.interfaces.user.wechat.miniapp.IMiniappUserBaseService;
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO;
|
||||
import ink.wgink.module.wechat.pojo.vos.miniapp.MiniAppUpdateInfoVO;
|
||||
|
||||
@ -17,7 +18,7 @@ import java.util.Map;
|
||||
* @Date: 2021/4/8 5:37 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IMiniappUserService {
|
||||
public interface IMiniappUserService extends IMiniappUserBaseService {
|
||||
|
||||
/**
|
||||
* 微信随机用户前缀
|
||||
|
@ -7,15 +7,19 @@ import ink.wgink.module.wechat.dao.miniapp.IMiniAppUserDao;
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO;
|
||||
import ink.wgink.module.wechat.pojo.vos.miniapp.MiniAppUpdateInfoVO;
|
||||
import ink.wgink.module.wechat.service.miniapp.IMiniappUserService;
|
||||
import ink.wgink.properties.wechat.miniapp.MiniappProperties;
|
||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.util.date.DateUtil;
|
||||
import ink.wgink.util.string.WStringUtil;
|
||||
import ink.wgink.util.verification.share.ShareCodeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -38,6 +42,8 @@ public class MiniappUserServiceImpl extends DefaultBaseService implements IMinia
|
||||
private IMiniAppUserDao miniappUserDao;
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
@Autowired
|
||||
private MiniappProperties miniappProperties;
|
||||
|
||||
@Override
|
||||
public String createAndReturnUserId(String appKey, String openId) {
|
||||
@ -63,9 +69,33 @@ public class MiniappUserServiceImpl extends DefaultBaseService implements IMinia
|
||||
params.put("isInitAccount", 1);
|
||||
params.put("gmtCreate", DateUtil.getTime());
|
||||
miniappUserDao.save(params);
|
||||
|
||||
Long id = Long.parseLong(params.get("id").toString());
|
||||
String userCode = ShareCodeUtil.gen(id);
|
||||
updateUserCode(openId, userCode);
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String userId) {
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return;
|
||||
}
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(userId);
|
||||
delete(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<String> userIds) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
miniappUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfo(String token, MiniAppUpdateInfoVO miniAppUpdateInfoVO) throws Exception {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
@ -128,4 +158,13 @@ public class MiniappUserServiceImpl extends DefaultBaseService implements IMinia
|
||||
params.put("openId", openId);
|
||||
return getPO(params);
|
||||
}
|
||||
|
||||
private void updateUserCode(String userCode, String openId) {
|
||||
Map<String, Object> params = getHashMap(6);
|
||||
params.put("userCode", userCode);
|
||||
params.put("appId", miniappProperties.getAppKey());
|
||||
params.put("openId", openId);
|
||||
miniappUserDao.updateUserCode(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ink.wgink.module.wechat.service.official.account;
|
||||
|
||||
import ink.wgink.interfaces.user.wechat.official.account.IOfficialAccountBaseService;
|
||||
import ink.wgink.module.wechat.enums.XmlEventTypeEnum;
|
||||
import ink.wgink.module.wechat.pojo.dtos.official.account.OfficialAccountUserDTO;
|
||||
import ink.wgink.module.wechat.pojo.pos.official.account.OfficialAccountUserPO;
|
||||
@ -20,7 +21,7 @@ import java.util.Map;
|
||||
* @Date: 2021/4/28 6:15 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IOfficialAccountUserService {
|
||||
public interface IOfficialAccountUserService extends IOfficialAccountBaseService {
|
||||
|
||||
/**
|
||||
* 公众号用户前缀
|
||||
|
@ -17,10 +17,12 @@ import ink.wgink.util.date.DateUtil;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
import ink.wgink.util.string.WStringUtil;
|
||||
import ink.wgink.util.verification.share.ShareCodeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -85,6 +87,27 @@ public class OfficialAccountUserServiceImpl extends DefaultBaseService implement
|
||||
updateUserCode(openId, userCode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(String userId) {
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return;
|
||||
}
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(userId);
|
||||
delete(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<String> userIds) {
|
||||
if (userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userIds", userIds);
|
||||
officialAccountUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(String openId, XmlEventTypeEnum xmlEventTypeEnum) {
|
||||
String time = DateUtil.getTime();
|
||||
@ -161,6 +184,7 @@ public class OfficialAccountUserServiceImpl extends DefaultBaseService implement
|
||||
|
||||
/**
|
||||
* 更新用户码(邀请码)
|
||||
*
|
||||
* @param openId
|
||||
* @param userCode
|
||||
*/
|
||||
@ -171,4 +195,5 @@ public class OfficialAccountUserServiceImpl extends DefaultBaseService implement
|
||||
params.put("userCode", userCode);
|
||||
officialAccountUserDao.updateUserCode(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
`app_id` varchar(255) DEFAULT NULL COMMENT 'appid',
|
||||
`open_id` varchar(255) DEFAULT NULL COMMENT 'openid',
|
||||
`user_id` varchar(255) DEFAULT NULL COMMENT '用户ID',
|
||||
`user_code` varchar(255) DEFAULT NULL COMMENT '用户码',
|
||||
`nick_name` varchar(255) DEFAULT NULL COMMENT '微信昵称',
|
||||
`avatar_url` varchar(500) DEFAULT NULL COMMENT '微信头像',
|
||||
`is_init_account` int(1) DEFAULT '0' COMMENT '是否初始化账户',
|
||||
@ -28,27 +29,43 @@
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `app_id` (`app_id`) USING BTREE,
|
||||
KEY `open_id` (`open_id`) USING BTREE,
|
||||
KEY `user_id` (`user_id`) USING BTREE
|
||||
KEY `user_id` (`user_id`) USING BTREE,
|
||||
KEY `user_code` (`user_code`) USING BTREE,
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='小程序用户';
|
||||
</update>
|
||||
|
||||
<!-- 保存 -->
|
||||
<insert id="save" parameterType="map" flushCache="true">
|
||||
<insert id="save" parameterType="map" flushCache="true" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||
INSERT INTO wechat_mini_app_user(
|
||||
app_id,
|
||||
open_id,
|
||||
user_id,
|
||||
user_code,
|
||||
is_init_account,
|
||||
gmt_create
|
||||
) VALUES(
|
||||
#{appId},
|
||||
#{openId},
|
||||
#{userId},
|
||||
#{userCode},
|
||||
#{isInitAccount},
|
||||
#{gmtCreate}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除用户 -->
|
||||
<delete id="delete" parameterType="map" flushCache="true">
|
||||
DELETE 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>
|
||||
</delete>
|
||||
|
||||
<!-- 更新信息 -->
|
||||
<update id="updateInfo" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
@ -74,12 +91,25 @@
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<!-- 更新用户码 -->
|
||||
<update id="updateUserCode" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
wechat_mini_app_user
|
||||
SET
|
||||
user_code = #{userCode}
|
||||
WHERE
|
||||
app_id = #{appId}
|
||||
AND
|
||||
open_id = #{openId}
|
||||
</update>
|
||||
|
||||
<!-- 列表 -->
|
||||
<select id="listPO" parameterType="map" resultMap="miniappUserPO" useCache="true">
|
||||
SELECT
|
||||
app_id,
|
||||
open_id,
|
||||
user_id,
|
||||
user_code,
|
||||
nick_name,
|
||||
avatar_url,
|
||||
is_init_account,
|
||||
@ -102,6 +132,7 @@
|
||||
app_id,
|
||||
open_id,
|
||||
user_id,
|
||||
user_code,
|
||||
nick_name,
|
||||
avatar_url,
|
||||
is_init_account,
|
||||
|
@ -39,7 +39,8 @@
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `app_id` (`app_id`) USING BTREE,
|
||||
KEY `open_id` (`open_id`) USING BTREE,
|
||||
KEY `user_id` (`user_id`) USING BTREE
|
||||
KEY `user_id` (`user_id`) USING BTREE,
|
||||
KEY `user_code` (`user_code`) USING BTREE,
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='小程序用户';
|
||||
</update>
|
||||
|
||||
@ -67,16 +68,16 @@
|
||||
</insert>
|
||||
|
||||
<!-- 删除 -->
|
||||
<update id="remove" parameterType="map" flushCache="true">
|
||||
<update id="delete" parameterType="map" flushCache="true">
|
||||
DELETE FROM
|
||||
wechat_official_account_user
|
||||
WHERE
|
||||
app_id = #{appId}
|
||||
AND
|
||||
open_ids IN
|
||||
<foreach collection="openIds" index="index" open="(" separator="," close=")">
|
||||
#{openIds[${index}]}
|
||||
</foreach>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<!-- 修改 -->
|
||||
|
@ -11,6 +11,8 @@ import ink.wgink.exceptions.base.SystemException;
|
||||
import ink.wgink.interfaces.app.IAppSignBaseService;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.manager.ISystemConfigManager;
|
||||
import ink.wgink.interfaces.user.wechat.miniapp.IMiniappUserBaseService;
|
||||
import ink.wgink.interfaces.user.wechat.official.account.IOfficialAccountBaseService;
|
||||
import ink.wgink.module.file.excel.error.AbstractErrorExcelHandler;
|
||||
import ink.wgink.module.file.service.IFileService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
@ -80,6 +82,10 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
private IFileService fileService;
|
||||
@Autowired(required = false)
|
||||
private IAppSignBaseService appSignBaseService;
|
||||
@Autowired(required = false)
|
||||
private IMiniappUserBaseService miniappUserBaseService;
|
||||
@Autowired(required = false)
|
||||
private IOfficialAccountBaseService officialAccountBaseService;
|
||||
|
||||
@Override
|
||||
public void save(UserVO userVO) {
|
||||
@ -123,6 +129,8 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
params.put("userIds", ids);
|
||||
setUpdateInfo(params);
|
||||
userDao.remove(params);
|
||||
// 删除关联用户
|
||||
deleteRelationUser(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -611,4 +619,20 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除关联用户
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
private void deleteRelationUser(List<String> userIds) {
|
||||
// 小程序关联用户
|
||||
if (miniappUserBaseService != null) {
|
||||
miniappUserBaseService.delete(userIds);
|
||||
}
|
||||
// 微信公众号关联用户
|
||||
if (officialAccountBaseService != null) {
|
||||
officialAccountBaseService.delete(userIds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user