use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class MailServiceImpl method send.
/**
* 发送评论邮件通知
*
* @param comment
* @param keyEnum
* @param audit
* @return
*/
@Override
@Async
public void send(Comment comment, TemplateKeyEnum keyEnum, boolean audit) {
if (comment == null || StringUtils.isEmpty(comment.getEmail())) {
this.sendToAdmin(comment);
return;
}
Map config = configService.getConfigs();
Template template = templateService.getTemplate(keyEnum);
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 subject = "评论回复通知";
if (audit) {
subject = "评论审核结果通知";
}
MailDetail mailDetail = new MailDetail(subject, comment.getEmail(), comment.getNickname(), mailContext);
send(mailDetail);
if (!audit) {
this.sendToAdmin(comment);
}
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class SysTemplateServiceImpl method getTemplate.
@Override
public Template getTemplate(String key) {
if (StringUtils.isEmpty(key)) {
return null;
}
SysTemplate entity = new SysTemplate();
entity.setRefKey(key);
entity = this.sysTemplateMapper.selectOne(entity);
return null == entity ? null : new Template(entity);
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class SysTemplateServiceImpl method getByPrimaryKey.
@Override
public Template getByPrimaryKey(Long primaryKey) {
Assert.notNull(primaryKey, "PrimaryKey不可为空!");
SysTemplate entity = sysTemplateMapper.selectByPrimaryKey(primaryKey);
return null == entity ? null : new Template(entity);
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class RestWebSiteController method robots.
@GetMapping(value = "/robots.txt", produces = { "text/plain" })
@BussinessLog(value = "查看robots", platform = PlatformEnum.WEB)
public String robots() {
Template template = templateService.getTemplate(TemplateKeyEnum.TM_ROBOTS);
Map<String, Object> map = new HashMap<>();
map.put("config", configService.getConfigs());
return FreeMarkerUtil.template2String(template.getRefValue(), map, true);
}
use of com.zyd.blog.business.entity.Template in project OneBlog by zhangyd-c.
the class RestWebSiteController method getSitemap.
private String getSitemap(TemplateKeyEnum key) {
Template template = templateService.getTemplate(key);
Map<String, Object> map = new HashMap<>();
map.put("articleTypeList", typeService.listAll());
map.put("articleTagsList", tagsService.listAll());
map.put("articleList", articleService.listAll());
map.put("config", configService.getConfigs());
return FreeMarkerUtil.template2String(template.getRefValue(), map, true);
}
Aggregations