From 06fccac0e2d6d8603f23b0f1eaccc0e0fbbb8885 Mon Sep 17 00:00:00 2001 From: daihh Date: Mon, 7 Nov 2022 18:31:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=85=8D=E7=BD=AE=E5=8F=8A?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/EmailServiceImpl.java | 16 ++++++++++++---- .../xboe/module/course/api/CourseManageApi.java | 2 ++ .../main/resources/application-dev.properties | 10 ++++++++-- .../main/resources/application-pre.properties | 6 ++++++ .../main/resources/application-pro.properties | 6 ++++++ .../main/resources/application-test.properties | 8 +++++++- 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/assistance/service/impl/EmailServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/module/assistance/service/impl/EmailServiceImpl.java index b597a0e1..0167994e 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/assistance/service/impl/EmailServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/assistance/service/impl/EmailServiceImpl.java @@ -8,8 +8,8 @@ import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.xboe.core.SysConstant; import com.xboe.core.utils.OkHttpUtil; import com.xboe.module.assistance.service.IEmailService; @@ -42,23 +42,31 @@ public class EmailServiceImpl implements IEmailService { // $r = TNetworkHelper::HttpPost($url, $arr); // var_dump($r); // } - private static final String PostUrl="https://u-pre.boe.com/api/b1/email/send"; + //private static final String PostUrl="https://u-pre.boe.com/api/b1/email/send"; @Override public void sendMail(String to, String subject, String htmlMsg, String from) throws Exception { + String cfgUrl=SysConstant.getConfigValue("xboe.email.url"); + if(StringUtils.isBlank(cfgUrl)) { + throw new Exception("发送邮件失败,未配置邮件信息"); + } + String cfgFrom=SysConstant.getConfigValue("xboe.email.from","boeu_learning@boe.com.cn"); + String cfgUser=SysConstant.getConfigValue("xboe.email.user"); + String cfgWord=SysConstant.getConfigValue("xboe.email.password"); + Map data=new HashMap(); data.put("to",to); data.put("subject",subject); data.put("content", htmlMsg); - data.put("fromName", "boeu_learning@boe.com.cn"); + data.put("fromName", cfgFrom); data.put("cc", ""); data.put("type", 0); ObjectMapper mapper=new ObjectMapper(); String json=mapper.writeValueAsString(data); String[] headers=new String[] {"Content-Type","application/json","Host","u.boe.com"}; - String rs=httpUtil.doPostJson(PostUrl,json,headers); + String rs=httpUtil.doPostJson(cfgUrl,json,headers); //System.out.println(mailInfo.toString()); //System.out.println(rs); if(StringUtils.isNotBlank(rs)) { diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java index 29b8fbff..4a92c146 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java @@ -475,6 +475,8 @@ public class CourseManageApi extends ApiBaseController{ if(!isLocalDevelopment()) { //只是非开发模式下才可以发送 service.sendMail(email,"课程审核提醒", htmlEmail,"数字化学习平台"); + }else { + //service.sendMail("daihaixing@bjxask.com","课程审核提醒", htmlEmail,"数字化学习平台"); } } catch (Exception ex) { diff --git a/servers/boe-server-all/src/main/resources/application-dev.properties b/servers/boe-server-all/src/main/resources/application-dev.properties index 45945a8d..86486645 100644 --- a/servers/boe-server-all/src/main/resources/application-dev.properties +++ b/servers/boe-server-all/src/main/resources/application-dev.properties @@ -9,7 +9,7 @@ spring.jpa.show-sql = true spring.jpa.hibernate.ddl-auto=update spring.datasource.driverClassName=com.mysql.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://192.168.0.11:3306/boeu_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull +spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boeu_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.username=root spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==) @@ -52,11 +52,17 @@ jasypt.encryptor.algorithm=PBEWithMD5AndDES jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator # elasticsearch config -xboe.elasticsearch.server.ip=192.168.0.11 +xboe.elasticsearch.server.ip=127.0.0.1 xboe.elasticsearch.server.port=9200 xboe.elasticsearch.server.user= xboe.elasticsearch.server.password= # 默认搜索的索引 xboe.elasticsearch.index.name=new_resource_list +## 邮件的配置 +xboe.email.url=https://u-pre.boe.com/api/b1/email/send +xboe.email.from=boeu_learning@boe.com.cn +xboe.email.user= +xboe.email.password= + diff --git a/servers/boe-server-all/src/main/resources/application-pre.properties b/servers/boe-server-all/src/main/resources/application-pre.properties index d65cdcdf..113dfa7a 100644 --- a/servers/boe-server-all/src/main/resources/application-pre.properties +++ b/servers/boe-server-all/src/main/resources/application-pre.properties @@ -48,3 +48,9 @@ xboe.elasticsearch.server.ip=10.251.129.25 xboe.elasticsearch.server.port=9200 xboe.elasticsearch.server.user=elastic xboe.elasticsearch.server.password=Boe@es123 + +## 邮件的配置 +xboe.email.url=https://u.boe.com/api/b1/email/send +xboe.email.from=boeu_learning@boe.com.cn +xboe.email.user= +xboe.email.password= diff --git a/servers/boe-server-all/src/main/resources/application-pro.properties b/servers/boe-server-all/src/main/resources/application-pro.properties index b748a5b6..fd18b2bb 100644 --- a/servers/boe-server-all/src/main/resources/application-pro.properties +++ b/servers/boe-server-all/src/main/resources/application-pro.properties @@ -85,3 +85,9 @@ xboe.elasticsearch.server.ip=127.0.0.1 xboe.elasticsearch.server.port=9200 xboe.elasticsearch.server.user=elastic xboe.elasticsearch.server.password=Boe@es123 + +## 邮件的配置 +xboe.email.url=https://u.boe.com/api/b1/email/send +xboe.email.from=boeu_learning@boe.com.cn +xboe.email.user= +xboe.email.password= diff --git a/servers/boe-server-all/src/main/resources/application-test.properties b/servers/boe-server-all/src/main/resources/application-test.properties index 0cc3cc67..790890e1 100644 --- a/servers/boe-server-all/src/main/resources/application-test.properties +++ b/servers/boe-server-all/src/main/resources/application-test.properties @@ -59,4 +59,10 @@ jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator xboe.elasticsearch.server.ip=10.251.129.25 xboe.elasticsearch.server.port=9200 xboe.elasticsearch.server.user=elastic -xboe.elasticsearch.server.password=Boe@es123 \ No newline at end of file +xboe.elasticsearch.server.password=Boe@es123 + +## 邮件的配置 +xboe.email.url=https://u-pre.boe.com/api/b1/email/send +xboe.email.from=boeu_learning@boe.com.cn +xboe.email.user= +xboe.email.password= \ No newline at end of file