use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class MailServiceImpl method sendToAdmin.
/**
* 发送到管理员的评论通知
*
* @param comment
*/
@Override
@Async
public void sendToAdmin(Comment comment) {
Map config = configService.getConfigs();
Template template = templateService.getTemplate(TemplateKeyEnum.TM_NEW_COMMENT);
String temXml = template.getRefValue();
Map<String, Object> map = new HashMap<>(2);
map.put("comment", comment);
map.put("config", config);
String mailContext = FreeMarkerUtil.template2String(temXml, map, true);
String adminEmail = (String) config.get("authorEmail");
if (StringUtils.isEmpty(adminEmail)) {
log.warn("[sendToAdmin]邮件发送失败!未指定系统管理员的邮箱地址");
return;
}
adminEmail = (adminEmail.contains("#") ? adminEmail.replace("#", "@") : adminEmail);
MailDetail mailDetail = new MailDetail("有新的评论消息", adminEmail, (String) config.get("authorName"), mailContext);
send(mailDetail);
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class MailServiceImpl method send.
/**
* 发送友情链接邮件通知
*
* @param link
* @param keyEnum
* @return
*/
@Override
@Async
public void send(Link link, TemplateKeyEnum keyEnum) {
if (!StringUtils.isEmpty(link.getEmail())) {
Map config = configService.getConfigs();
Template template = templateService.getTemplate(keyEnum);
String temXml = template.getRefValue();
Map<String, Object> map = new HashMap<>(2);
map.put("link", link);
map.put("config", config);
String mailContext = FreeMarkerUtil.template2String(temXml, map, true);
MailDetail mailDetail = new MailDetail("友情链接操作通知", link.getEmail(), link.getName(), mailContext);
send(mailDetail);
}
this.sendToAdmin(link);
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class MailServiceImpl method sendToAdmin.
/**
* 发送到管理员的友链操作通知
*
* @param link
*/
@Override
@Async
public void sendToAdmin(Link link) {
Map config = configService.getConfigs();
Template template = templateService.getTemplate(TemplateKeyEnum.TM_LINKS_TO_ADMIN);
String temXml = template.getRefValue();
Map<String, Object> map = new HashMap<>(1);
map.put("link", link);
String mailContext = FreeMarkerUtil.template2String(temXml, map, true);
String adminEmail = (String) config.get(ConfigKeyEnum.AUTHOR_EMAIL.getKey());
if (StringUtils.isEmpty(adminEmail)) {
log.warn("[sendToAdmin]邮件发送失败!未指定系统管理员的邮箱地址");
return;
}
adminEmail = (adminEmail.contains("#") ? adminEmail.replace("#", "@") : adminEmail);
MailDetail mailDetail = new MailDetail("有新的友链消息", adminEmail, (String) config.get(ConfigKeyEnum.AUTHOR_NAME.getKey()), mailContext);
send(mailDetail);
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class SysTemplateServiceImpl method listAll.
@Override
public List<Template> listAll() {
List<SysTemplate> entityList = sysTemplateMapper.selectAll();
if (CollectionUtils.isEmpty(entityList)) {
return null;
}
List<Template> list = new ArrayList<>();
for (SysTemplate entity : entityList) {
list.add(new Template(entity));
}
return list;
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class SysTemplateServiceImpl method findPageBreakByCondition.
/**
* 分页查询
*
* @param vo
* @return
*/
@Override
public PageInfo<Template> findPageBreakByCondition(TemplateConditionVO vo) {
PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
List<SysTemplate> list = sysTemplateMapper.findPageBreakByCondition(vo);
if (CollectionUtils.isEmpty(list)) {
return null;
}
List<Template> boList = new ArrayList<>();
for (SysTemplate sysTemplate : list) {
boList.add(new Template(sysTemplate));
}
PageInfo bean = new PageInfo<SysTemplate>(list);
bean.setList(boList);
return bean;
}
Aggregations