feat:REQ-1419 代码逻辑优化

This commit is contained in:
zuoqinbo 2023-10-26 15:54:48 +08:00
parent 458cceb68c
commit dc7beb1ece
5 changed files with 14 additions and 23 deletions

View File

@ -53,12 +53,12 @@ public class RobotInfoResp {
/**
* 机器人已上架消息模板数量
*/
private Integer msgTemplateValid;
private Integer msgTemplateValid = 0;
/**
* 机器人关联消息模板总数量
*/
private Integer msgTemplateTotal;
private Integer msgTemplateTotal = 0;
/**

View File

@ -43,7 +43,7 @@ public class RobotInfoController implements RobotInfoApi {
@Override
public ApiResult<RobotInfoResp> updateRobotInfo(UpdateRobotInfoReq updateRobotInfoReq) {
RobotInfoResp robotTagResp = infoService.updateRobotInfo(updateRobotInfoReq,iNotifyService);
RobotInfoResp robotTagResp = infoService.updateRobotInfo(updateRobotInfoReq, iNotifyService);
return ApiResult.ok(robotTagResp);
}

View File

@ -211,6 +211,10 @@ public class AccountService {
if (CollectionUtils.isNotEmpty(userAccountRespList)) {
userAccountAll.addAll(userAccountRespList);
} else {
if (appTypeEnum == AppTypeEnum.SYSTEM) {
log.warn("该接口不允许创建AppType=[system]账户!");
continue;
}
UserAccountReq userAccountReq = new UserAccountReq();
userAccountReq.setAppType(appTypeEnum.getCode());
userAccountReq.setUserId(accountAbsentQuery.getPersonId());

View File

@ -17,7 +17,6 @@ import cn.axzo.im.entity.MessageHistory;
import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
@ -78,7 +77,7 @@ public class MessageService {
public int msgSendPersonOfOneBatch = 100;
@Transactional
@Transactional(rollbackFor = Exception.class)
public List<MessageDispatchResp> sendMessage(MessageInfo messageInfo) {
String msgTemplateId = messageInfo.getMsgTemplateId();
MessageDispatchRequest messageRequest = buildMessageDispatchRequest(messageInfo);
@ -248,6 +247,11 @@ public class MessageService {
.eq(AccountRegister::getAppType, appType.getCode()).one();
if (accountRegister == null || StringUtils.isEmpty(accountRegister.getImAccount())) {
//返回未注册的IM账户信息
MessageDispatchResp messageDispatchResp = buildMessageDispatchResp(null,
messageRequest.getFrom(), accountRegister.getImAccount(), appType.getCode(), 0L);
messageDispatchResp.setRegistered(false);
messageDispatchRespList.add(messageDispatchResp);
log.warn("接收用户账户[" + personId + "],appType[" + appType.getCode() + "],未注册IM账户!");
return;
}

View File

@ -93,7 +93,7 @@ public class RobotInfoService {
robotInfoOld.setStatus(updateRobotInfoReq.getStatus());
}
RobotInfo robotInfoNew = robotInfoDao.saveOrUpdateRobotInfo(robotInfoOld);
if (iNotifyService != null && robotInfoNew !=null) {
if (iNotifyService != null && robotInfoNew != null) {
iNotifyService.notifyRobotAccountChange(robotInfoNew.getRobotId());
}
assert robotInfoNew != null;
@ -138,7 +138,6 @@ public class RobotInfoService {
robotTag.setUseCount(useCount);
});
robotInfoResp.setRobotTagList(robotTagsResp);
fillRobotRespOfMsgTemplate(robotInfoResp);
return robotInfoResp;
}
@ -172,25 +171,9 @@ public class RobotInfoService {
robotTag.setUseCount(useCount);
});
});
robotInfoRespList.forEach(this::fillRobotRespOfMsgTemplate);
return pageOfRobotInfoResp;
}
private void fillRobotRespOfMsgTemplate(RobotInfoResp robotInfoResp) {
// if (robotInfoResp == null) {
// return;
// }
// List<String> msgTemplateIdList = templateService.queryRobotMsgTemplateIds(robotInfoResp.getRobotId());
// robotInfoResp.setMsgTemplateList(msgTemplateIdList);
// List<RobotMsgTemplateResp> robotMsgTemplateRespList = templateService.fillMsgTemplateList(msgTemplateIdList);
// robotInfoResp.setMsgTemplateTotal(robotMsgTemplateRespList.size());
// //计算已上架|已启用的消息模板
// int msgTemplateTotal = (int) robotMsgTemplateRespList.stream().filter(robotMsgTemplateResp ->
// StatusEnum.ENABLE.getDesc().equals(robotMsgTemplateResp.getStatus())).count();
// robotInfoResp.setMsgTemplateValid(msgTemplateTotal);
}
public List<RobotInfoResp> queryRunningRobotList() {
List<RobotInfo> runningRobots = robotInfoDao.queryRunningRobotList();
if (CollectionUtils.isEmpty(runningRobots)) {