Bläddra i källkod

refactor: some change

linwenhua 3 år sedan
förälder
incheckning
8d281eed2d

+ 1 - 0
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/InformMessageContentRecordServiceImpl.java

@@ -14,6 +14,7 @@ import org.springframework.beans.BeanUtils;
 import javax.annotation.Resource;
 
 /**
+ * message content record service
  * @author linwenhua
  * @date 2022-07-01 10:08
  **/

+ 7 - 11
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/WeChatAppletMessageHandler.java

@@ -1,15 +1,13 @@
 package com.inspur.customer.service.inform.handler;
 
 import com.inspur.customer.object.inform.CommonMessageCO;
+import com.inspur.inform.client.wechat.applet.IWxAppletUserMessageService;
 import com.inspur.inform.constants.UserMsgType;
+import com.inspur.inform.constants.applet.WxAppletMessageTemplate;
 import com.inspur.inform.object.applet.message.WxAppletUserMessageDto;
-import org.apache.commons.io.IOUtils;
-import org.springframework.core.io.ClassPathResource;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Component;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
 import java.util.Iterator;
 
 /**
@@ -20,14 +18,12 @@ import java.util.Iterator;
 @Component
 public class WeChatAppletMessageHandler extends AbstractMessageHandler {
 
-    private static final String FILE_PATH_PRE = "appletMessage/";
+    @DubboReference
+    private IWxAppletUserMessageService wxAppletUserMessageService;
 
-    private static final String FILE_PATH_SUF = ".RTF";
-
-    public WxAppletUserMessageDto makeWeChatAppletMessage(CommonMessageCO commonMessageCo, String fileName) throws IOException {
+    public WxAppletUserMessageDto makeWeChatAppletMessage(CommonMessageCO commonMessageCo, String fileName) {
         // get content
-        String filePath = FILE_PATH_PRE + fileName + FILE_PATH_SUF;
-        String content = getTemplate(filePath);
+        String content = wxAppletUserMessageService.getTemplate(WxAppletMessageTemplate.getTemplateByFilePath(fileName));
         Iterator<String> integer = commonMessageCo.getMessageMap().keySet().iterator();
         String key;
         while (integer.hasNext()) {

+ 5 - 3
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/WeChatMessageHandler.java

@@ -28,17 +28,19 @@ public class WeChatMessageHandler extends AbstractMessageHandler {
     private static final String FILE_PATH_SUF = ".json";
 
     public WechatMessage makeWeChatMessage(CommonMessageCO commonMessageCo, List<String> openIds, String fileName) throws IOException {
-        WechatRealMessage wechatRealMessage = getRealMessge(fileName);
+        WechatRealMessage wechatRealMessage = getRealMessage(fileName);
         commonMessageCo.getMessageMap().forEach((key, word) -> {
             WechatKeyword wechatKeyword = wechatRealMessage.getData().get(key);
             String keywordValue = wechatKeyword.getValue();
             String[] words = word.split("/");
             wechatKeyword.setValue(MessageFormat.format(keywordValue, words));
         });
-        return new WechatMessage(wechatRealMessage, openIds);
+        WechatMessage wechatMessage = new WechatMessage(wechatRealMessage);
+        wechatMessage.setInformAddresses(openIds);
+        return wechatMessage;
     }
 
-    private WechatRealMessage getRealMessge(String fileName) throws IOException {
+    private WechatRealMessage getRealMessage(String fileName) throws IOException {
         // get content
         String filePath = FILE_PATH_PRE + fileName + FILE_PATH_SUF;
         String content = getTemplate(filePath);

+ 2 - 2
smsb-customer-manager-client/src/main/java/com/inspur/customer/context/inform/MessageTemplateEnum.java

@@ -20,11 +20,11 @@ public enum MessageTemplateEnum {
     /**
      * AI 审核库存
      */
-    AI_AUDIT_CREDIT_INSUFFICIENT_WARN("AiAuditCreditInsufficientWarn", 1, "AiAuditCreditInsufficientWarn",  "AiAuditCreditInsufficientWarn"),
+    AI_AUDIT_CREDIT_INSUFFICIENT_WARN("AiAuditCreditInsufficientWarn", 1, "AiAuditCreditInsufficientWarn",  "appletMessage/AiAuditCreditInsufficientWarn.RTF"),
     /**
      * 媒资 AI 不通过异常
      */
-    AI_AUDIT_NON_COMPLIANCE("EmailVerifyTemplate", 1, "wechat",  ""),
+    AI_AUDIT_NON_COMPLIANCE("EmailVerifyTemplate", 1, "wechat",  "appletMessage/AiAuditMediaWarn.RTF"),
     ;
 
     @Getter