forked from github/dataease
Merge pull request #1259 from dataease/pr@dev@refactor_format_code_style
refactor: 格式化代码
This commit is contained in:
commit
ee4fe0cb7f
@ -5,7 +5,6 @@ import io.dataease.plugins.config.SpringContextUtil;
|
|||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -13,26 +12,26 @@ import java.net.UnknownHostException;
|
|||||||
|
|
||||||
public class ServletUtils {
|
public class ServletUtils {
|
||||||
|
|
||||||
public static HttpServletRequest request(){
|
public static HttpServletRequest request() {
|
||||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpServletResponse response(){
|
public static HttpServletResponse response() {
|
||||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
HttpServletResponse response = servletRequestAttributes.getResponse();
|
HttpServletResponse response = servletRequestAttributes.getResponse();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setToken(String token){
|
public static void setToken(String token) {
|
||||||
HttpServletResponse httpServletResponse = response();
|
HttpServletResponse httpServletResponse = response();
|
||||||
httpServletResponse.addHeader("Access-Control-Expose-Headers", "Authorization");
|
httpServletResponse.addHeader("Access-Control-Expose-Headers", "Authorization");
|
||||||
httpServletResponse.setHeader(AuthConstants.TOKEN_KEY, token);
|
httpServletResponse.setHeader(AuthConstants.TOKEN_KEY, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getToken(){
|
public static String getToken() {
|
||||||
HttpServletRequest request = request();
|
HttpServletRequest request = request();
|
||||||
String token = request.getHeader(AuthConstants.TOKEN_KEY);
|
String token = request.getHeader(AuthConstants.TOKEN_KEY);
|
||||||
return token;
|
return token;
|
||||||
@ -49,10 +48,8 @@ public class ServletUtils {
|
|||||||
}
|
}
|
||||||
Environment environment = SpringContextUtil.getBean(Environment.class);
|
Environment environment = SpringContextUtil.getBean(Environment.class);
|
||||||
Integer port = environment.getProperty("server.port", Integer.class);
|
Integer port = environment.getProperty("server.port", Integer.class);
|
||||||
return "http://" + hostAddress + ":"+port ;
|
return "http://" + hostAddress + ":" + port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
|||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.quartz.*;
|
import org.quartz.*;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -31,17 +32,17 @@ public abstract class TaskHandler implements InitializingBean {
|
|||||||
}
|
}
|
||||||
Class executor = this.getClass();
|
Class executor = this.getClass();
|
||||||
String cron = cron(taskEntity);
|
String cron = cron(taskEntity);
|
||||||
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, executor , cron, start, end, jobDataMap(taskEntity));
|
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, executor, cron, start, end, jobDataMap(taskEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected abstract JobDataMap jobDataMap( GlobalTaskEntity taskEntity);
|
protected abstract JobDataMap jobDataMap(GlobalTaskEntity taskEntity);
|
||||||
|
|
||||||
private String cron(GlobalTaskEntity taskEntity) {
|
private String cron(GlobalTaskEntity taskEntity) {
|
||||||
if(taskEntity.getRateType() == -1) {
|
if (taskEntity.getRateType() == -1) {
|
||||||
return taskEntity.getRateVal();
|
return taskEntity.getRateVal();
|
||||||
}
|
}
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
Date date = null;
|
Date date = null;
|
||||||
try {
|
try {
|
||||||
@ -82,20 +83,18 @@ public abstract class TaskHandler implements InitializingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void removeTask(ScheduleManager scheduleManager, GlobalTaskEntity taskEntity) {
|
||||||
public void removeTask(ScheduleManager scheduleManager, GlobalTaskEntity taskEntity){
|
|
||||||
JobKey jobKey = new JobKey(taskEntity.getTaskId().toString());
|
JobKey jobKey = new JobKey(taskEntity.getTaskId().toString());
|
||||||
TriggerKey triggerKey = new TriggerKey(taskEntity.getTaskId().toString());
|
TriggerKey triggerKey = new TriggerKey(taskEntity.getTaskId().toString());
|
||||||
scheduleManager.removeJob(jobKey, triggerKey);
|
scheduleManager.removeJob(jobKey, triggerKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeTask(ScheduleManager scheduleManager, GlobalTaskEntity taskEntity) throws Exception{
|
public void executeTask(ScheduleManager scheduleManager, GlobalTaskEntity taskEntity) throws Exception {
|
||||||
JobKey jobKey = new JobKey(taskEntity.getTaskId().toString());
|
JobKey jobKey = new JobKey(taskEntity.getTaskId().toString());
|
||||||
scheduleManager.fireNow(jobKey);
|
scheduleManager.fireNow(jobKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//判断任务是否过期
|
//判断任务是否过期
|
||||||
public Boolean taskExpire(Long endTime) {
|
public Boolean taskExpire(Long endTime) {
|
||||||
if (ObjectUtils.isEmpty(endTime)) return false;
|
if (ObjectUtils.isEmpty(endTime)) return false;
|
||||||
@ -108,12 +107,12 @@ public abstract class TaskHandler implements InitializingBean {
|
|||||||
String beanName = null;
|
String beanName = null;
|
||||||
String className = this.getClass().getName();
|
String className = this.getClass().getName();
|
||||||
className = className.substring(className.lastIndexOf(".") + 1);
|
className = className.substring(className.lastIndexOf(".") + 1);
|
||||||
if(className.length() > 1) {
|
if (className.length() > 1) {
|
||||||
beanName = className.substring(0, 1).toLowerCase() + className.substring(1);
|
beanName = className.substring(0, 1).toLowerCase() + className.substring(1);
|
||||||
} else {
|
} else {
|
||||||
beanName = className.toLowerCase();
|
beanName = className.toLowerCase();
|
||||||
}
|
}
|
||||||
TaskStrategyFactory.register( beanName, this);
|
TaskStrategyFactory.register(beanName, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package io.dataease.job.sechedule.strategy;
|
package io.dataease.job.sechedule.strategy;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class TaskStrategyFactory {
|
public class TaskStrategyFactory {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static Map<String, TaskHandler> strategyMap = new ConcurrentHashMap<>();
|
private static Map<String, TaskHandler> strategyMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static TaskHandler getInvokeStrategy(String name) {
|
public static TaskHandler getInvokeStrategy(String name) {
|
||||||
|
@ -46,9 +46,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
|||||||
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
||||||
XpackEmailTemplateDTO emailTemplateDTO = emailXpackService.emailTemplate(taskEntity.getTaskId());
|
XpackEmailTemplateDTO emailTemplateDTO = emailXpackService.emailTemplate(taskEntity.getTaskId());
|
||||||
jobDataMap.put("emailTemplate", emailTemplateDTO);
|
jobDataMap.put("emailTemplate", emailTemplateDTO);
|
||||||
|
SysUserEntity creator = authUserServiceImpl.getUserByIdNoCache(taskEntity.getCreator());
|
||||||
/*SysUserEntity creator = CommonBeanFactory.getBean(AuthUserService.class).getUserById(taskEntity.getCreator());*/
|
|
||||||
SysUserEntity creator =authUserServiceImpl.getUserByIdNoCache(taskEntity.getCreator());
|
|
||||||
jobDataMap.put("creator", creator);
|
jobDataMap.put("creator", creator);
|
||||||
return jobDataMap;
|
return jobDataMap;
|
||||||
}
|
}
|
||||||
@ -56,10 +54,10 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
// 插件没有加载 空转
|
// 插件没有加载 空转
|
||||||
if(!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) return;
|
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) return;
|
||||||
|
|
||||||
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
||||||
GlobalTaskEntity taskEntity = (GlobalTaskEntity)jobDataMap.get("taskEntity");
|
GlobalTaskEntity taskEntity = (GlobalTaskEntity) jobDataMap.get("taskEntity");
|
||||||
if (taskExpire(taskEntity.getEndTime())) {
|
if (taskExpire(taskEntity.getEndTime())) {
|
||||||
ScheduleManager scheduleManager = SpringContextUtil.getBean(ScheduleManager.class);
|
ScheduleManager scheduleManager = SpringContextUtil.getBean(ScheduleManager.class);
|
||||||
removeTask(scheduleManager, taskEntity);
|
removeTask(scheduleManager, taskEntity);
|
||||||
@ -81,7 +79,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
|||||||
return CommonBeanFactory.getBean(EmailTaskHandler.class);
|
return CommonBeanFactory.getBean(EmailTaskHandler.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long saveInstance(GlobalTaskInstance taskInstance){
|
public Long saveInstance(GlobalTaskInstance taskInstance) {
|
||||||
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
||||||
return emailXpackService.saveInstance(taskInstance);
|
return emailXpackService.saveInstance(taskInstance);
|
||||||
}
|
}
|
||||||
@ -109,11 +107,10 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendReport(GlobalTaskInstance taskInstance, XpackEmailTemplateDTO emailTemplateDTO, SysUserEntity user) {
|
public void sendReport(GlobalTaskInstance taskInstance, XpackEmailTemplateDTO emailTemplateDTO, SysUserEntity user) {
|
||||||
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
||||||
try{
|
try {
|
||||||
byte[] bytes = emailXpackService.printData(panelUrl(emailTemplateDTO.getPanelId()), tokenByUser(user), buildPixel(emailTemplateDTO));
|
byte[] bytes = emailXpackService.printData(panelUrl(emailTemplateDTO.getPanelId()), tokenByUser(user), buildPixel(emailTemplateDTO));
|
||||||
// 下面继续执行发送邮件的
|
// 下面继续执行发送邮件的
|
||||||
String recipients = emailTemplateDTO.getRecipients();
|
String recipients = emailTemplateDTO.getRecipients();
|
||||||
@ -125,7 +122,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
|||||||
}
|
}
|
||||||
emailService.sendWithImage(recipients, emailTemplateDTO.getTitle(), contentStr, bytes);
|
emailService.sendWithImage(recipients, emailTemplateDTO.getTitle(), contentStr, bytes);
|
||||||
success(taskInstance);
|
success(taskInstance);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
error(taskInstance, e);
|
error(taskInstance, e);
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
@ -143,14 +140,12 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
|||||||
pixelEntity.setX(String.valueOf(x));
|
pixelEntity.setX(String.valueOf(x));
|
||||||
pixelEntity.setY(String.valueOf(y));
|
pixelEntity.setY(String.valueOf(y));
|
||||||
return pixelEntity;
|
return pixelEntity;
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String tokenByUser(SysUserEntity user) {
|
private String tokenByUser(SysUserEntity user) {
|
||||||
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(user.getUsername()).build();
|
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(user.getUsername()).build();
|
||||||
String token = JWTUtils.sign(tokenInfo, user.getPassword());
|
String token = JWTUtils.sign(tokenInfo, user.getPassword());
|
||||||
|
@ -22,6 +22,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Api(tags = "xpack:定时报告")
|
@Api(tags = "xpack:定时报告")
|
||||||
@ -42,7 +43,7 @@ public class XEmailTaskServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public void save(@RequestBody XpackEmailCreate param) throws Exception{
|
public void save(@RequestBody XpackEmailCreate param) throws Exception {
|
||||||
XpackEmailTaskRequest request = param.fillContent();
|
XpackEmailTaskRequest request = param.fillContent();
|
||||||
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
||||||
request.setCreator(AuthUtils.getUser().getUserId());
|
request.setCreator(AuthUtils.getUser().getUserId());
|
||||||
@ -59,7 +60,7 @@ public class XEmailTaskServer {
|
|||||||
XpackEmailCreate xpackEmailCreate = new XpackEmailCreate();
|
XpackEmailCreate xpackEmailCreate = new XpackEmailCreate();
|
||||||
byte[] bytes = taskForm.getContent();
|
byte[] bytes = taskForm.getContent();
|
||||||
|
|
||||||
if(ObjectUtils.isNotEmpty(bytes)) {
|
if (ObjectUtils.isNotEmpty(bytes)) {
|
||||||
String emailContent;
|
String emailContent;
|
||||||
try {
|
try {
|
||||||
emailContent = new String(bytes, "UTF-8");
|
emailContent = new String(bytes, "UTF-8");
|
||||||
@ -91,8 +92,8 @@ public class XEmailTaskServer {
|
|||||||
}
|
}
|
||||||
String imageUrl = "/system/ui/image/" + fileId;
|
String imageUrl = "/system/ui/image/" + fileId;
|
||||||
String html = "<div>" +
|
String html = "<div>" +
|
||||||
"<h2>"+content+"</h2>" +
|
"<h2>" + content + "</h2>" +
|
||||||
"<img style='width: 100%;' id='"+panelId+"' src='"+imageUrl+"' />" +
|
"<img style='width: 100%;' id='" + panelId + "' src='" + imageUrl + "' />" +
|
||||||
"</div>";
|
"</div>";
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
@ -141,7 +142,7 @@ public class XEmailTaskServer {
|
|||||||
result.setX(String.valueOf(x));
|
result.setX(String.valueOf(x));
|
||||||
result.setY(String.valueOf(y));
|
result.setY(String.valueOf(y));
|
||||||
return result;
|
return result;
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.activation.DataHandler;
|
import javax.activation.DataHandler;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.mail.Message;
|
import javax.mail.Message;
|
||||||
@ -49,18 +48,16 @@ public class EmailService {
|
|||||||
private static final String SMTP_CONNECTIONTIMEOUT_VAL = "5000";
|
private static final String SMTP_CONNECTIONTIMEOUT_VAL = "5000";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SystemParameterMapper systemParameterMapper;
|
private SystemParameterMapper systemParameterMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param to 收件人
|
* @param to 收件人
|
||||||
* @param title 标题
|
* @param title 标题
|
||||||
* @param content 内容
|
* @param content 内容
|
||||||
*/
|
*/
|
||||||
public void send(String to, String title, String content) {
|
public void send(String to, String title, String content) {
|
||||||
if (StringUtils.isBlank(to)) return ;
|
if (StringUtils.isBlank(to)) return;
|
||||||
MailInfo mailInfo = proxy().mailInfo();
|
MailInfo mailInfo = proxy().mailInfo();
|
||||||
JavaMailSenderImpl driver = driver(mailInfo);
|
JavaMailSenderImpl driver = driver(mailInfo);
|
||||||
|
|
||||||
@ -69,7 +66,7 @@ public class EmailService {
|
|||||||
try {
|
try {
|
||||||
helper = new MimeMessageHelper(mimeMessage, true);
|
helper = new MimeMessageHelper(mimeMessage, true);
|
||||||
helper.setFrom(driver.getUsername());
|
helper.setFrom(driver.getUsername());
|
||||||
helper.setSubject(title );
|
helper.setSubject(title);
|
||||||
helper.setText(content, true);
|
helper.setText(content, true);
|
||||||
helper.setTo(to);
|
helper.setTo(to);
|
||||||
driver.send(mimeMessage);
|
driver.send(mimeMessage);
|
||||||
@ -80,7 +77,7 @@ public class EmailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendWithImage(String to, String title, String content, byte[] bytes) {
|
public void sendWithImage(String to, String title, String content, byte[] bytes) {
|
||||||
if (StringUtils.isBlank(to)) return ;
|
if (StringUtils.isBlank(to)) return;
|
||||||
MailInfo mailInfo = proxy().mailInfo();
|
MailInfo mailInfo = proxy().mailInfo();
|
||||||
JavaMailSenderImpl driver = driver(mailInfo);
|
JavaMailSenderImpl driver = driver(mailInfo);
|
||||||
MimeMessage mimeMessage = driver.createMimeMessage();
|
MimeMessage mimeMessage = driver.createMimeMessage();
|
||||||
@ -92,7 +89,7 @@ public class EmailService {
|
|||||||
MimeBodyPart text = new MimeBodyPart();
|
MimeBodyPart text = new MimeBodyPart();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
text.setContent("<h2>"+content+"</h2>" + "<br/><img src='cid:"+uuid+"' />", "text/html; charset=gb2312");
|
text.setContent("<h2>" + content + "</h2>" + "<br/><img src='cid:" + uuid + "' />", "text/html; charset=gb2312");
|
||||||
image.setDataHandler(png);
|
image.setDataHandler(png);
|
||||||
image.setContentID(uuid);
|
image.setContentID(uuid);
|
||||||
MimeMultipart multipart = new MimeMultipart();
|
MimeMultipart multipart = new MimeMultipart();
|
||||||
@ -107,7 +104,6 @@ public class EmailService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
// DEException.throwException(Translator.get("connection_failed"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,13 +211,13 @@ public class EmailService {
|
|||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
DEException.throwException(Translator.get("connection_failed"));
|
DEException.throwException(Translator.get("connection_failed"));
|
||||||
}
|
}
|
||||||
if(!StringUtils.isBlank(recipients)){
|
if (!StringUtils.isBlank(recipients)) {
|
||||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||||
MimeMessageHelper helper;
|
MimeMessageHelper helper;
|
||||||
try {
|
try {
|
||||||
helper = new MimeMessageHelper(mimeMessage, true);
|
helper = new MimeMessageHelper(mimeMessage, true);
|
||||||
helper.setFrom(javaMailSender.getUsername());
|
helper.setFrom(javaMailSender.getUsername());
|
||||||
helper.setSubject("DataEase测试邮件 " );
|
helper.setSubject("DataEase测试邮件 ");
|
||||||
helper.setText("这是一封测试邮件,邮件发送成功", true);
|
helper.setText("这是一封测试邮件,邮件发送成功", true);
|
||||||
helper.setTo(recipients);
|
helper.setTo(recipients);
|
||||||
javaMailSender.send(mimeMessage);
|
javaMailSender.send(mimeMessage);
|
||||||
|
Loading…
Reference in New Issue
Block a user