feat:REQ-1419 代码逻辑优化

This commit is contained in:
zuoqinbo 2023-10-26 11:11:39 +08:00
parent 13043288de
commit 20e16b576b
2 changed files with 5 additions and 2 deletions

View File

@ -111,9 +111,11 @@ public class NimChannelService implements IMChannelProvider {
if (queryAccountResponse.getStatus() == SUCCESS_CODE) {
QueryAccountResp queryInfoResp = JSONUtil.toBean(queryAccountResponse.body(), QueryAccountResp.class);
if (CollectionUtils.isNotEmpty(queryInfoResp.getUinfos())) {
//AccountInfo中没有返回Token相关字段
QueryAccountResp.AccountInfo accountInfo = queryInfoResp.getUinfos().get(0);
NimAccountInfo userAccount = new NimAccountInfo();
userAccount.setAccid(accountInfo.getAccid());
//返回RegisterResponse对象中没有Token
registerResponse.setInfo(userAccount);
} else {
log.error("请求网易云信getUserInfo:{},返回结果:{},用户信息异常:{}",

View File

@ -115,8 +115,7 @@ public class AccountService {
if (StringUtils.isBlank(accountRegister.getImAccount())) {
//2.重新注册账户,如果已注册就查询该账户信息
UserAccountResp accountResp = createNimAccount(userId, userIdWrapper, headImageUrl, nickName);
if (accountResp != null && StringUtils.isNotBlank(accountResp.getImAccount())
&& StringUtils.isNotBlank(accountResp.getToken())) {
if (accountResp != null && StringUtils.isNotBlank(accountResp.getImAccount())) {
accountRegister.setImAccount(accountResp.getImAccount());
accountRegister.setToken(accountResp.getToken());
accountRegister.setAppKey(appKey);
@ -135,12 +134,14 @@ public class AccountService {
.desc(accountResp.getDesc())
.build();
}
accountResp.setAppType(appType);
return accountResp;
}
//1.1 如果已经创建直接返回
return UserAccountResp.builder()
.imAccount(accountRegister.getImAccount())
.userId(userId)
.appType(appType)
.token(accountRegister.getToken())
.build();