From f8ab133a7dc20562c25a092a402266f5e7b0b296 Mon Sep 17 00:00:00 2001
From: Jack <jack.su@pollex.com.tw>
Date: 星期一, 24 一月 2022 10:29:38 +0800
Subject: [PATCH] Merge branch 'Phase3' of ssh://dev.pollex.com.tw:29418/pcalife/PAM into Phase3

---
 pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java b/pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java
index 2fe2642..05d8d73 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java
+++ b/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);

--
Gitblit v1.8.0