feat:REQ-1419 移除消息模板服务依赖
This commit is contained in:
parent
8a004c40af
commit
af67ade3f1
@ -29,7 +29,6 @@
|
||||
<dependency>
|
||||
<groupId>cn.axzo.im.center</groupId>
|
||||
<artifactId>im-center-common</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package cn.axzo.im.center.api.vo.req;
|
||||
|
||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -19,10 +22,11 @@ public class MessageInfo {
|
||||
/**
|
||||
* 发送消息到App端
|
||||
* 工人端、企业端、服务器
|
||||
* WORKER、ENTERPRISE、SYSTEM
|
||||
* cm、cmp、system
|
||||
* @See cn.axzo.im.center.common.enums.AppTypeEnum
|
||||
*/
|
||||
@NotNull(message = "消息接收端类型列表")
|
||||
private List<String> appTypeList;
|
||||
private List<AppTypeEnum> appTypeList;
|
||||
|
||||
|
||||
/**
|
||||
@ -63,5 +67,5 @@ public class MessageInfo {
|
||||
/**
|
||||
* 消息扩展信息
|
||||
*/
|
||||
private Map<String, String> extendsInfo;
|
||||
private Map<String, String> extendsInfo = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@ -26,10 +26,6 @@
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>msg-center-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
@ -104,12 +100,6 @@
|
||||
<dependency>
|
||||
<groupId>cn.axzo.im.center</groupId>
|
||||
<artifactId>im-center-api</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.trade</groupId>
|
||||
<artifactId>trade-data-security-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -60,9 +60,12 @@ public class MessageService {
|
||||
messageBody.setMsgContent(messageInfo.getMsgContent());
|
||||
messageBody.setMsgHeader(messageInfo.getMsgHeader());
|
||||
messageBody.setMsgBody(messageInfo.getMsgTemplateContent());
|
||||
Map<String,String> defaultExtMap = Maps.newHashMap();
|
||||
defaultExtMap.put("msgTemplateId",messageInfo.getMsgTemplateId());
|
||||
defaultExtMap.putAll(messageInfo.getExtendsInfo());
|
||||
Map<String, String> defaultExtMap = Maps.newHashMap();
|
||||
defaultExtMap.put("msgTemplateId", messageInfo.getMsgTemplateId());
|
||||
if (messageInfo.getExtendsInfo() != null) {
|
||||
defaultExtMap.putAll(messageInfo.getExtendsInfo());
|
||||
}
|
||||
|
||||
messageBody.setExt(defaultExtMap);
|
||||
messageRequest.setBody(JSONUtil.toJsonStr(messageBody));
|
||||
//设置IM消息发送者账号
|
||||
|
||||
@ -7,7 +7,6 @@ import cn.axzo.im.center.api.vo.req.RobotInfoReq;
|
||||
import cn.axzo.im.center.api.vo.req.RobotPageQuery;
|
||||
import cn.axzo.im.center.api.vo.req.UpdateRobotInfoReq;
|
||||
import cn.axzo.im.center.api.vo.resp.RobotInfoResp;
|
||||
import cn.axzo.im.center.api.vo.resp.RobotMsgTemplateResp;
|
||||
import cn.axzo.im.center.api.vo.resp.RobotTagResp;
|
||||
import cn.axzo.im.center.common.enums.RobotStatusEnum;
|
||||
import cn.axzo.im.channel.netease.INotifyService;
|
||||
@ -16,7 +15,6 @@ import cn.axzo.im.dao.repository.RobotTagDao;
|
||||
import cn.axzo.im.entity.RobotInfo;
|
||||
import cn.axzo.im.entity.RobotTag;
|
||||
import cn.axzo.im.utils.BeanConvertUtils;
|
||||
import cn.axzo.msg.center.service.enums.StatusEnum;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -180,17 +178,17 @@ public class RobotInfoService {
|
||||
|
||||
|
||||
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);
|
||||
// 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() {
|
||||
|
||||
@ -11,9 +11,6 @@ import cn.axzo.im.dao.repository.RobotMsgTemplateDao;
|
||||
import cn.axzo.im.entity.RobotInfo;
|
||||
import cn.axzo.im.entity.RobotMsgTemplate;
|
||||
import cn.axzo.msg.center.service.template.client.MessageTemplateClient;
|
||||
import cn.axzo.msg.center.service.template.response.MessageTemplatePageResponse;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import cn.azxo.framework.common.utils.StringUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -42,10 +39,6 @@ public class RobotMsgTemplateService {
|
||||
@Resource
|
||||
private RobotMsgTemplateDao robotMsgTemplateDao;
|
||||
|
||||
|
||||
@Resource
|
||||
private MessageTemplateClient messageTemplateClient;
|
||||
|
||||
@Resource
|
||||
private RobotInfoDao robotInfoDao;
|
||||
|
||||
@ -58,17 +51,6 @@ public class RobotMsgTemplateService {
|
||||
return robotMsgTemplate.getMsgTemplateList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<RobotMsgTemplateResp> queryRobotMsgTemplateList(String robotId) {
|
||||
RobotMsgTemplate robotMsgTemplate = robotMsgTemplateDao.lambdaQuery().eq(RobotMsgTemplate::getIsDelete, 0)
|
||||
.eq(RobotMsgTemplate::getRobotId, robotId).one();
|
||||
if (robotMsgTemplate == null) {
|
||||
return null;
|
||||
}
|
||||
return fillMsgTemplateList(robotMsgTemplate.getMsgTemplateList());
|
||||
}
|
||||
|
||||
public PageResp<RobotMsgTemplateResp> queryRobotMsgTemplateOfPage(RobotMsgTemplatePageQuery msgTemplatePageQuery) {
|
||||
String robotId = msgTemplatePageQuery.getRobotId();
|
||||
int pageSize = msgTemplatePageQuery.getPageSize();
|
||||
@ -87,44 +69,21 @@ public class RobotMsgTemplateService {
|
||||
List<String> msgTemplates = partition.get(currentPage);
|
||||
robotMsgTemplate.setMsgTemplateList(msgTemplates);
|
||||
robotMsgTemplate.setRobotId(robotId);
|
||||
List<RobotMsgTemplateResp> templateRespList = msgTemplates.stream().map(new Function<String, RobotMsgTemplateResp>() {
|
||||
@Override
|
||||
public RobotMsgTemplateResp apply(String templateId) {
|
||||
RobotMsgTemplateResp templateResp = new RobotMsgTemplateResp();
|
||||
templateResp.setMsgTemplateId(templateId);
|
||||
return templateResp;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
return PageResp.list((long) currentPage, (long) pageSize,
|
||||
(long) pageTotal, fillMsgTemplateList(msgTemplates));
|
||||
(long) pageTotal, templateRespList);
|
||||
} else {
|
||||
return PageResp.list((long) page, (long) pageSize, 0L, Lists.newArrayList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据消息模板ID查询消息模板内容
|
||||
*
|
||||
* @param msgTemplateIds 消息模板ID集合
|
||||
* @return 返回消息模板内容集合
|
||||
*/
|
||||
public List<RobotMsgTemplateResp> fillMsgTemplateList(List<String> msgTemplateIds) {
|
||||
if (CollectionUtils.isEmpty(msgTemplateIds)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
CommonResponse<List<MessageTemplatePageResponse>> commonResponse = messageTemplateClient.listByCodes(msgTemplateIds);
|
||||
List<MessageTemplatePageResponse> templatePageResponses = commonResponse.getData();
|
||||
if (CollectionUtils.isNotEmpty(templatePageResponses)) {
|
||||
List<RobotMsgTemplateResp> robotMsgTemplates = templatePageResponses.stream().map(messageTemplatePageResponse -> {
|
||||
RobotMsgTemplateResp robotMsgTemplateResp = new RobotMsgTemplateResp();
|
||||
|
||||
robotMsgTemplateResp.setMsgTemplateId(messageTemplatePageResponse.getTemplateCode());
|
||||
robotMsgTemplateResp.setStatus(messageTemplatePageResponse.getStatus().getDesc());
|
||||
robotMsgTemplateResp.setMsgCategory(StringUtils.join(messageTemplatePageResponse.getGroupNodeNamePaths(), "|"));
|
||||
robotMsgTemplateResp.setMsgContent(messageTemplatePageResponse.getContent());
|
||||
robotMsgTemplateResp.setMsgHeader(messageTemplatePageResponse.getTitle());
|
||||
robotMsgTemplateResp.setMsgType(messageTemplatePageResponse.getCategory().getMessage());
|
||||
robotMsgTemplateResp.setMsgName(messageTemplatePageResponse.getTemplateName());
|
||||
return robotMsgTemplateResp;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return robotMsgTemplates;
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
public List<String> queryRobotIdByTemplate(String templateId) {
|
||||
List<RobotMsgTemplate> robotMsgTemplateList = robotMsgTemplateDao.queryAllMsgTemplateList();
|
||||
List<String> robotIdList = Lists.newArrayList();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user