|
|
@@ -7,6 +7,7 @@ import com.uas.message.mail.domain.MailLog;
|
|
|
import com.uas.message.mail.service.MailService;
|
|
|
import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
@@ -31,17 +32,18 @@ public class RestMailServiceImpl implements MailService {
|
|
|
/**
|
|
|
* 邮件服务主机地址
|
|
|
*/
|
|
|
- private static final String MAIL_CONSOLE_HOST = "http://10.10.100.23:28029/";
|
|
|
+ @Value("#{sys.messageServiceIp ?: 'http://message.ubtob.com/'}")
|
|
|
+ private String MAIL_CONSOLE_HOST;
|
|
|
|
|
|
/**
|
|
|
* 发送邮件给单个人url
|
|
|
*/
|
|
|
- private static final String MAIL_SEND_URL = MAIL_CONSOLE_HOST + "mail/send";
|
|
|
+ private String MAIL_SEND_URL = "mail/send";
|
|
|
|
|
|
/**
|
|
|
* 发送邮件给多个人 url
|
|
|
*/
|
|
|
- private static final String MAIL_SEND_MANY_URL = MAIL_CONSOLE_HOST + "mail/send/o2m";
|
|
|
+ private String MAIL_SEND_MANY_URL = "mail/send/o2m";
|
|
|
|
|
|
@Autowired
|
|
|
public RestMailServiceImpl(RestTemplate restTemplate) {
|
|
|
@@ -86,7 +88,7 @@ public class RestMailServiceImpl implements MailService {
|
|
|
object.put("params", params);
|
|
|
|
|
|
HttpEntity<String> formEntity = new HttpEntity<String>(object.toJSONString(), headers);
|
|
|
- ResponseEntity<MailLog> responseEntity = restTemplate.postForEntity(MAIL_SEND_URL, formEntity, MailLog.class);
|
|
|
+ ResponseEntity<MailLog> responseEntity = restTemplate.postForEntity(MAIL_CONSOLE_HOST + MAIL_SEND_URL, formEntity, MailLog.class);
|
|
|
return responseEntity.getBody();
|
|
|
}
|
|
|
|
|
|
@@ -110,7 +112,7 @@ public class RestMailServiceImpl implements MailService {
|
|
|
object.put("params", params);
|
|
|
|
|
|
HttpEntity<String> formEntity = new HttpEntity<String>(object.toJSONString(), headers);
|
|
|
- ResponseEntity<String> responseEntity = restTemplate.postForEntity(MAIL_SEND_MANY_URL, formEntity, String.class);
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.postForEntity(MAIL_CONSOLE_HOST + MAIL_SEND_MANY_URL, formEntity, String.class);
|
|
|
List<MailLog> mailLogs = FastjsonUtils.fromJsonArray(responseEntity.getBody(), MailLog.class);
|
|
|
return mailLogs;
|
|
|
}
|