From 124ca536917b5eebe059bb98745f6743c52a6836 Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Tue, 23 Aug 2022 18:47:32 +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