inleft
2022-08-23 124ca536917b5eebe059bb98745f6743c52a6836
snowy-main/src/main/java/vip/xiaonuo/modular/task/EMailTaskRunner.java
@@ -2,6 +2,7 @@
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;
@@ -47,8 +48,15 @@
                .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("本次无提醒消息条数。。");
@@ -60,12 +68,12 @@
        //发送邮件
        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);
@@ -81,8 +89,5 @@
    }
    public static void main(String[] args) {
        System.out.println(DateUtil.offsetDay(DateUtil.date(), -1));
    }
}