feat:机器人消息模板管理

This commit is contained in:
zuoqinbo 2023-10-13 15:04:22 +08:00
parent 73e8458a8a
commit 28c0f10625
3 changed files with 26 additions and 17 deletions

View File

@ -58,6 +58,13 @@ public class AccountRegister extends BaseEntity<AccountRegister> implements Ser
*/ */
@TableField("app_key") @TableField("app_key")
private String appKey; private String appKey;
/**
* channel 服务提供商
*/
@TableField("channel_provider")
private String channelProvider;
/** /**
* 账户类型:机器人普通用户 * 账户类型:机器人普通用户
*/ */

View File

@ -60,9 +60,8 @@ public class AccountService {
} }
String userIdWrapper = userAccountReq.getUserId() + "_" + appTypeEnum.getCode(); String userIdWrapper = userAccountReq.getUserId() + "_" + appTypeEnum.getCode();
//后续AppKey可能会更换普通用户通过userIdappTypeappKey维度来保证唯一性 //后续AppKey可能会更换普通用户通过userIdappTypeappKey维度来保证唯一性
UserAccountResp userAccountResp = createAccountRegister(userAccountReq.getUserId(), UserAccountResp userAccountResp = createAccountRegister(userAccountReq.getUserId(), userIdWrapper, appType,
userIdWrapper, appType, AccountTypeEnum.USER.getCode(), AccountTypeEnum.USER.getCode(), userAccountReq.getHeadImageUrl(), userAccountReq.getNickName());
userAccountReq.getHeadImageUrl(), userAccountReq.getNickName());
return userAccountResp; return userAccountResp;
} }
@ -82,23 +81,25 @@ public class AccountService {
public UserAccountResp createAccountRegister(String userId, String userIdWrapper, String appType, public UserAccountResp createAccountRegister(String userId, String userIdWrapper, String appType,
String accountType, String headImageUrl, String nickName) { String accountType, String headImageUrl, String nickName) {
//1.检查账户是否已经创建 //1.检查账户是否已经创建
String appKey = imChannelProvider.getProviderAppKey();
AccountRegister accountRegister = accountRegisterDao.lambdaQuery().eq(AccountRegister::getIsDelete, 0) AccountRegister accountRegister = accountRegisterDao.lambdaQuery().eq(AccountRegister::getIsDelete, 0)
.eq(AccountRegister::getAccountWrapper, userIdWrapper) .eq(AccountRegister::getAccountWrapper, userIdWrapper)
.eq(AccountRegister::getAppKey, imChannelProvider.getProviderAppKey()).one(); .eq(AccountRegister::getAppKey, appKey).one();
if (accountRegister == null) { if (accountRegister == null) {
accountRegister = new AccountRegister(); accountRegister = new AccountRegister();
} }
if (StringUtils.isBlank(accountRegister.getImAccount())) { if (StringUtils.isBlank(accountRegister.getImAccount())) {
//2.重新注册账户,如果已注册就查询该账户信息 //2.重新注册账户,如果已注册就查询该账户信息
UserAccountResp accountResp = createNimAccount(userIdWrapper, headImageUrl, nickName, imChannelProvider.getProviderAppKey()); UserAccountResp accountResp = createNimAccount(userIdWrapper, headImageUrl, nickName, appKey);
if (accountResp != null && StringUtils.isNotBlank(accountResp.getImAccount())) { if (accountResp != null && StringUtils.isNotBlank(accountResp.getImAccount())) {
accountRegister.setImAccount(accountResp.getImAccount()); accountRegister.setImAccount(accountResp.getImAccount());
accountRegister.setToken(accountResp.getToken()); accountRegister.setToken(accountResp.getToken());
accountRegister.setAppKey(imChannelProvider.getProviderAppKey()); accountRegister.setAppKey(appKey);
accountRegister.setAccountId(userId); accountRegister.setAccountId(userId);
accountRegister.setAccountWrapper(userIdWrapper); accountRegister.setAccountWrapper(userIdWrapper);
accountRegister.setAccountType(accountType); accountRegister.setAccountType(accountType);
accountRegister.setAppType(appType); accountRegister.setAppType(appType);
accountRegister.setChannelProvider(imChannelProvider.getProviderAppKey());
accountRegister.setCreateAt(new Date()); accountRegister.setCreateAt(new Date());
accountRegister.setUpdateAt(new Date()); accountRegister.setUpdateAt(new Date());
accountRegisterDao.saveOrUpdate(accountRegister); accountRegisterDao.saveOrUpdate(accountRegister);

View File

@ -38,17 +38,18 @@ create index idx_im_robot_id
CREATE TABLE IF NOT EXISTS im_account_register CREATE TABLE IF NOT EXISTS im_account_register
( (
id bigint auto_increment comment '主键', id bigint auto_increment comment '主键',
account_id varchar(100) not null comment '用户账户:机器人robotId、普通用户userId', account_id varchar(100) not null comment '用户账户:机器人robotId、普通用户userId',
account_wrapper varchar(100) not null comment '普通用户账户,通过appType包装', account_wrapper varchar(100) not null comment '普通用户账户,通过appType包装',
app_key varchar(100) not null comment '网易云信app_key', app_key varchar(100) not null comment '网易云信app_key',
im_account varchar(100) default '' not null comment '已生成IM账号', channel_provider varchar(20) not null comment 'IM服务提供商',
account_type varchar(20) default '' not null comment '账户类型:机器人、普通用户', im_account varchar(100) default '' not null comment '已生成IM账号',
app_type varchar(20) default '' not null comment 'App终端类型:WORKER、ENTERPRISE、SYSTEM', account_type varchar(20) default '' not null comment '账户类型:机器人、普通用户',
token varchar(100) default '' not null comment '网易云信静态token', app_type varchar(20) default '' not null comment 'App终端类型:WORKER、ENTERPRISE、SYSTEM',
is_delete tinyint default 0 not null comment '未删除0,删除id', token varchar(100) default '' not null comment '网易云信静态token',
create_at datetime default CURRENT_TIMESTAMP not null comment '创建时间', is_delete tinyint default 0 not null comment '未删除0,删除id',
update_at datetime default CURRENT_TIMESTAMP not null comment '更新时间', create_at datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_at datetime default CURRENT_TIMESTAMP not null comment '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = InnoDB ) ENGINE = InnoDB
DEFAULT CHARSET = utf8 comment 'IM注册账户表'; DEFAULT CHARSET = utf8 comment 'IM注册账户表';