mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-18 23:36:52 +08:00
提交配置及邮件配置修改
This commit is contained in:
@@ -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<String,Object> data=new HashMap<String,Object>();
|
||||
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)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user