From 692560004358b1d0272f8e2a1bb57d7637ed550c Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Thu, 7 Nov 2024 15:34:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=B2=A1=E6=9C=89=E4=BF=9D=E6=8C=81=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lanyuanxiaoyao/digtal/market/runner/PushRunner.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lanyuanxiaoyao/digtal/market/runner/PushRunner.kt b/src/main/kotlin/com/lanyuanxiaoyao/digtal/market/runner/PushRunner.kt index aa2e22a..5772899 100644 --- a/src/main/kotlin/com/lanyuanxiaoyao/digtal/market/runner/PushRunner.kt +++ b/src/main/kotlin/com/lanyuanxiaoyao/digtal/market/runner/PushRunner.kt @@ -4,6 +4,7 @@ import com.lanyuanxiaoyao.digtal.market.ArticleRepository import com.lanyuanxiaoyao.digtal.market.sender.DingtalkSender import jakarta.annotation.Resource import org.slf4j.LoggerFactory +import org.springframework.data.domain.Sort import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service @@ -16,12 +17,12 @@ class PushRunner : Runner { @Scheduled(cron = "0 30 9,12,15,18,21 * * ?") override fun run() { - val articles = articleRepository.findAll { root, _, builder -> + val articles = articleRepository.findAll({ root, _, builder -> builder.or( builder.equal(root.get("pushed"), false), builder.isNull(root.get("pushed")), ) - } + }, Sort.by(Sort.Direction.DESC, "createTime")) try { DingtalkSender().send("近期要闻", mapOf("articles" to articles.take(10))) articles.forEach { articleRepository.updatePushedById(it.id, true) }