REQ-1898: 适当抽象

This commit is contained in:
yanglin 2024-01-14 18:07:07 +08:00
parent 186540128a
commit 08e935c894
2 changed files with 15 additions and 12 deletions

View File

@ -10,8 +10,8 @@ import cn.axzo.msg.center.domain.entity.MessageRecordV3;
import cn.axzo.msg.center.inside.notices.service.impl.v3.EventMappingProcessor;
import cn.axzo.msg.center.inside.notices.service.impl.v3.ImClient;
import cn.axzo.msg.center.inside.notices.utils.FunctionalTransactionTemplate;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@ -26,19 +26,18 @@ import static java.util.stream.Collectors.toMap;
*/
@Component
@Scope("prototype")
@RequiredArgsConstructor
public class MessageMappingProcessor implements EventMappingProcessor {
@Autowired
private MessageRecordV3Dao messageRecordV3Dao;
@Autowired
private FunctionalTransactionTemplate transactionTemplate;
@Autowired
private TerminalAppMapping terminalAppMapping;
@Autowired
private MessageTemplateParser templateParser;
@Autowired
private ImClient imClient;
private final MessageRecordV3Dao messageRecordV3Dao;
private final FunctionalTransactionTemplate transactionTemplate;
private final TerminalAppMapping terminalAppMapping;
private final MessageTemplateParser templateParser;
private final ImClient imClient;
/**
* @Scope("prototype") -> we're good
*/
@Setter
private TemplateMessage template;
@ -65,7 +64,7 @@ public class MessageMappingProcessor implements EventMappingProcessor {
@Override
public TemplateSendResultV3 buildTemplateSendResult() {
TemplateSendResultV3 templateResult = new TemplateSendResultV3();
templateResult.setTemplateCode(template.getTemplate().getCode());
templateResult.setTemplateCode(template.getTemplateCode());
templateResult.setBizActionCategory(template.getConfig().getCategory());
for (MessageRecordV3 message : template.getMessageRecords()) {
templateResult.addResult(new MessageSendResultV3(

View File

@ -43,6 +43,10 @@ public class TemplateMessage {
private String title;
private String content;
String getTemplateCode() {
return template.getCode();
}
Collection<Long> getMessageIds() {
return getMessageRecords().stream()
.map(MessageRecordV3::getId)