| | |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.lang.Dict; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.template.Template; |
| | | import cn.hutool.extra.template.TemplateConfig; |
| | | import cn.hutool.extra.template.TemplateEngine; |
| | |
| | | .eq(BlogArticleComment::getIsRemind, MyConstant.No) |
| | | .ge(BlogArticleComment::getCreateDate, DateUtil.offsetDay(DateUtil.date(), -1)) |
| | | .select(BlogArticleComment::getId, BlogArticleComment::getVisitorNickName, BlogArticleComment::getCommentContent) |
| | | .last("limit 100") |
| | | .last("limit 10") |
| | | .list(); |
| | | |
| | | int unReadCount = commentService.lambdaQuery() |
| | | .ne(BlogArticleComment::getVisitorNickName, MyConstant.inleft) |
| | | .eq(BlogArticleComment::getIsRead, MyConstant.No) |
| | | .eq(BlogArticleComment::getIsRemind, MyConstant.No) |
| | | .ge(BlogArticleComment::getCreateDate, DateUtil.offsetDay(DateUtil.date(), -1)) |
| | | .count(); |
| | | |
| | | if (commentList.size() == 0) { |
| | | log.info("本次无提醒消息条数。。"); |
| | |
| | | //发送邮件 |
| | | Dict dict = Dict.create() |
| | | .set("contentList", commentList) |
| | | .set("sendContent", commentList.size()); |
| | | .set("sendContent", StrUtil.format("新增了 {} 条未读信息", unReadCount)); |
| | | String result = template.render(dict); |
| | | |
| | | SendMailParam param = new SendMailParam(); |
| | | param.setContent(result); |
| | | param.setTitle("邮箱自提醒任务..\n"); |
| | | param.setTitle(StrUtil.format("邮箱定时任务(msg:{})..\n", unReadCount)); |
| | | param.setTo(MyConstant.email); |
| | | mailSender.sendMailHtml(param); |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(DateUtil.offsetDay(DateUtil.date(), -1)); |
| | | } |
| | | |
| | | } |