live环境部署
This commit is contained in:
parent
f1add310dc
commit
b3c0b217e0
@ -22,16 +22,19 @@ import cn.axzo.im.entity.RobotInfo;
|
||||
import cn.axzo.im.entity.bo.AccountQueryParam;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -68,6 +71,14 @@ public class AccountService {
|
||||
@Resource
|
||||
private Environment environment;
|
||||
|
||||
|
||||
/**
|
||||
* 网易云信liveEnv环境配置
|
||||
* 其他环境都是空,只有live环境有值
|
||||
*/
|
||||
@Value("${im-center.env.live:}")
|
||||
public String liveEnvPrefix;
|
||||
|
||||
/**
|
||||
* 创建IM账户
|
||||
*
|
||||
@ -80,8 +91,7 @@ public class AccountService {
|
||||
if (appTypeEnum == null) {
|
||||
throw new ServiceException("当前appType,服务器不支持该类型!!");
|
||||
}
|
||||
String env = environment.getProperty("spring.profiles.active");
|
||||
String userIdWrapper = env + userAccountReq.getUserId() + "_" + appTypeEnum.getCode();
|
||||
String userIdWrapper = buildUserIdWrapper(userAccountReq.getUserId(), userAccountReq.getAppType());
|
||||
//后续AppKey可能会更换,普通用户通过userId、appType、appKey维度来保证数据库唯一性
|
||||
UserAccountResp userAccountResp = createAccountRegister(userAccountReq.getUserId(), userIdWrapper, appType,
|
||||
AccountTypeEnum.USER.getCode(), userAccountReq.getHeadImageUrl(), userAccountReq.getNickName());
|
||||
@ -92,6 +102,11 @@ public class AccountService {
|
||||
return userAccountResp;
|
||||
}
|
||||
|
||||
private String buildUserIdWrapper(String userId, String appType) {
|
||||
String env = environment.getProperty("spring.profiles.active");
|
||||
String userIdWrapper = liveEnvPrefix + "_" + env + userId + "_" + appType;
|
||||
return userIdWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建IM账户 - 用于自定义通知
|
||||
@ -103,8 +118,7 @@ public class AccountService {
|
||||
if (appTypeEnum == null) {
|
||||
throw new ServiceException("当前appType,服务器不支持该类型!!");
|
||||
}
|
||||
String env = environment.getProperty("spring.profiles.active");
|
||||
String userIdWrapper = env + userAccountReq.getUserId() + "_" + appTypeEnum.getCode();
|
||||
String userIdWrapper = buildUserIdWrapper(userAccountReq.getUserId(), appTypeEnum.getCode());
|
||||
|
||||
String appKey = imChannelProvider.getProviderAppKey();
|
||||
AccountRegister customAccountRegister = queryCustomAccount(AccountTypeEnum.CUSTOM,
|
||||
@ -226,6 +240,10 @@ public class AccountService {
|
||||
|
||||
public List<UserAccountResp> queryAccountInfo(@Valid AccountQuery accountQuery) {
|
||||
//如果存在多个appKey,一个账户会有多条数据,分别对应不同的appKey
|
||||
if (StringUtils.isEmpty(accountQuery.getImAccount())) {
|
||||
String userIdWrapper = buildUserIdWrapper(accountQuery.getAccountId(), accountQuery.getAppType());
|
||||
accountQuery.setImAccount(userIdWrapper);
|
||||
}
|
||||
List<AccountRegister> accountRegisterList = accountRegisterDao.lambdaQuery().eq(AccountRegister::getIsDelete, 0)
|
||||
.eq(StringUtils.isNoneBlank(accountQuery.getImAccount()), AccountRegister::getImAccount,
|
||||
accountQuery.getImAccount())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user