保誠-保戶業務員媒合平台
Jack
2022-01-18 2f57dcc8883b62a4e006c634dd945cb3c7ae63c9
pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java
@@ -39,7 +39,12 @@
    SpringTemplateEngine springTemplateEngine;
    public SendSMSResponse sendMsgBySMS(String toMobile, String content) throws SendSMSFailException {
        SMS smsProperties = applicationProperties.getSms();
       if(!applicationProperties.isSendNotifyMsg()) {
//          return getMockSMSResponse();
          return null;
       }
       SMS smsProperties = applicationProperties.getSms();
        SendSMSRequest sendSMSRequest = new SendSMSRequest();
        sendSMSRequest.setpKey(UUID.randomUUID().toString());
@@ -76,14 +81,20 @@
        }
    }
    public String sendMsgByEmail(String from, String to, String subject, String content, boolean htmlFormat) throws SendEmailFailException{
        return sendMsgByEmail(from, to, subject, content, htmlFormat, Collections.emptyList(), Collections.emptyList());
//    private SendSMSResponse getMockSMSResponse() {
//       SendSMSResponse mock = new SendSMSResponse();
//       mock.set
//      return null;
//   }
   public String sendMsgByEmail(String to, String subject, String content, boolean htmlFormat) throws SendEmailFailException{
        return sendMsgByEmail(to, subject, content, htmlFormat, Collections.emptyList(), Collections.emptyList());
    }
    public String sendMsgByEmail(
        String fromAddress, String toAddress, String subject, String content, boolean htmlFormat, List<String> toCCAddress,
        List<String> attachments) throws SendEmailFailException
    {
    public String sendMsgByEmail(String toAddress, String subject, String content, boolean htmlFormat, List<String> toCCAddress,
        List<String> attachments) throws SendEmailFailException {
       String fromAddress = applicationProperties.getEmail().getSenderEmail();
        SendMailRequest sendMailRequest = new SendMailRequest();
        sendMailRequest.setSendMailAddresses(Collections.singletonList(toAddress));
        sendMailRequest.setFrom(fromAddress);
@@ -98,7 +109,10 @@
    }
    public String sendMsgByEmail(SendMailRequest sendMailRequest) throws SendEmailFailException{
        try {
       if(!applicationProperties.isSendNotifyMsg()) {
          return null;
       }
       try {
            ResponseEntity<String> responseEntity =
                HttpRequestUtil.postWithJson( applicationProperties.getEmail().getUrl(), sendMailRequest, String.class);
            log.debug("responseEntity = {}", responseEntity);