From 1e152bbcfb357073d8bcf0b51fe701e3fb81540d Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Mon, 22 Aug 2022 23:22:00 +0800 Subject: [PATCH] 修正邮箱拉取条数 添加日志上下篇 --- snowy-main/src/main/java/vip/xiaonuo/modular/task/EMailTaskRunner.java | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diff --git a/snowy-main/src/main/java/vip/xiaonuo/modular/task/EMailTaskRunner.java b/snowy-main/src/main/java/vip/xiaonuo/modular/task/EMailTaskRunner.java index ce20c60..48d7877 100644 --- a/snowy-main/src/main/java/vip/xiaonuo/modular/task/EMailTaskRunner.java +++ b/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)); - } } -- Gitblit v1.9.1