use of cn.dubidubi.model.base.dto.MailDTO in project dubidubi by lzzzz4.
the class MailJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
// 得到传入的jobDataMap,每次执行任务需要 图片的地址与发件人的地址
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
String str = jobDataMap.getString("str");
try (ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(Base64.decodeBase64(str));
ObjectInputStream objectInputStream = new ObjectInputStream(arrayInputStream)) {
PicUrlToBase64DTO toBase64DTO = (PicUrlToBase64DTO) objectInputStream.readObject();
List<String> mail = toBase64DTO.getMail();
int length = mail.size();
for (int i = 0; i < length; i++) {
MailDTO dto = new MailDTO();
dto.setMail(mail.get(i));
dto.setTitle("欢迎订阅图片服务");
// 得到所有的图片链接
List<String> list = toBase64DTO.getList();
StringBuilder builder = new StringBuilder();
for (String string : list) {
builder.append("<img src='" + string + "' />");
}
dto.setContent(builder.toString());
MailUtils.sendPicMail(dto);
}
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
use of cn.dubidubi.model.base.dto.MailDTO in project dubidubi by lzzzz4.
the class MailController method mailConfirm.
/**
* @Description: 发送邮箱验证码
* @data :@param mailFromWxDTO
* @data :@param request
* @data :@return
* @date :2018年3月9日下午8:44:34
*/
@RequestMapping("/mailConfirm")
@ResponseBody
public MailBindResult mailConfirm(MailFromWxDTO mailFromWxDTO, HttpServletRequest request) {
MailBindResult mailBindResult = new MailBindResult();
MailDTO dto = new MailDTO();
String code = MailUtils.randomSecurityCode();
dto.setContent(code);
dto.setMail(mailFromWxDTO.getMail());
dto.setTitle("欢迎绑定邮箱");
request.getSession().setAttribute("code", code);
LoggerFactory.getLogger(this.getClass()).info("开始绑定邮箱:" + mailFromWxDTO.getMail());
// 将正确的验证码放入对象
MailUtils.sendMail(dto);
System.out.println("验证码为" + code);
mailBindResult.setResult(code);
return mailBindResult;
}
use of cn.dubidubi.model.base.dto.MailDTO in project dubidubi by lzzzz4.
the class BaiduMailJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDetail detail = context.getJobDetail();
JobDataMap jobDataMap = detail.getJobDataMap();
String str = jobDataMap.getString("str");
try (ByteArrayInputStream in = new ByteArrayInputStream(Base64.decodeBase64(str));
ObjectInputStream inputStream = new ObjectInputStream(in)) {
PicUrlToBase64DTO pic = (PicUrlToBase64DTO) inputStream.readObject();
System.out.println(pic);
List<String> list = pic.getMail();
List<String> picList = pic.getList();
System.out.println(picList);
MailDTO dto = new MailDTO();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < picList.size(); i++) {
// 为奇数
if (i % 2 == 0 || i == 0) {
builder.append("<img src='").append(picList.get(i)).append("'/><br/>");
} else {
builder.append("<h2>").append(picList.get(i)).append("</h2>");
}
}
// 为订阅者的openid每个邮箱发送邮件
for (String string : list) {
System.out.println(string);
dto.setMail(string);
dto.setTitle("百度图片");
// 发送所有的图片链接
dto.setContent(builder.toString());
MailUtils.sendPicMail(dto);
}
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations