保誠-保戶業務員媒合平台
wayne
2022-01-24 b8a9ab562c0d87de1d0c1ee2e51c2d8b7883f5b0
Merge branch 'stmp' into Phase3
修改3個檔案
35 ■■■■ 已變更過的檔案
pamapi/src/main/java/com/pollex/pam/config/Constants.java 2 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java 19 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/resources/config/application-pollex.yml 14 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/config/Constants.java
@@ -30,5 +30,7 @@
     */
    public static final int SEND_EXPIRING_NOTIFY_LIMIT = 1;
    public static final String SPRING_PROFILE_POLLEX_DEVELOPMENT = "pollex";
    private Constants() {}
}
pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pollex.pam.config.ApplicationProperties;
import com.pollex.pam.config.ApplicationProperties.SMS;
import com.pollex.pam.config.Constants;
import com.pollex.pam.repository.ConsultantRepository;
import com.pollex.pam.service.dto.*;
import com.pollex.pam.service.util.HttpRequestUtil;
@@ -11,9 +12,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.thymeleaf.spring5.SpringTemplateEngine;
import tech.jhipster.config.JHipsterConstants;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
@@ -37,6 +41,12 @@
    @Autowired
    SpringTemplateEngine springTemplateEngine;
    @Autowired
    Environment environment;
    @Autowired
    MailService mailService;
    public SendSMSResponse sendMsgBySMS(String toMobile, String content) throws SendSMSFailException {
        if(!applicationProperties.isSendNotifyMsg()) {
@@ -110,8 +120,17 @@
    public String sendMsgByEmail(SendMailRequest sendMailRequest) throws SendEmailFailException{
        if(!applicationProperties.isSendNotifyMsg()) {
            if(environment.acceptsProfiles(Profiles.of(Constants.SPRING_PROFILE_POLLEX_DEVELOPMENT))) {
                String subject = sendMailRequest.getSubject();
                String content = sendMailRequest.getContent();
                boolean isHtml = sendMailRequest.isHtmlFormat();
                sendMailRequest.getSendMailAddresses().forEach(receiver -> mailService.sendEmail(receiver, subject, content, false, isHtml));
            }
            return null;
        }
        try {
            ResponseEntity<String> responseEntity =
                HttpRequestUtil.postWithJson( applicationProperties.getEmail().getUrl(), sendMailRequest, String.class);
pamapi/src/main/resources/config/application-pollex.yml
@@ -43,10 +43,16 @@
    # Remove 'faker' if you do not want the sample data to be loaded automatically
    contexts: pollex, faker
  mail:
    host: localhost
    port: 25
    username:
    password:
    host: smtp.gmail.com
    port: 587
    username: pollex.testing@gmail.com
    password: ilismmmhtscppxft
    properties:
      mail:
        smtp:
          auth: true
          starttls:
            enable: true
  messages:
    cache-duration: PT1S # 1 second, see the ISO 8601 standard
  thymeleaf: