fix: 修复文章推送没有保持排序
This commit is contained in:
@@ -4,6 +4,7 @@ import com.lanyuanxiaoyao.digtal.market.ArticleRepository
|
|||||||
import com.lanyuanxiaoyao.digtal.market.sender.DingtalkSender
|
import com.lanyuanxiaoyao.digtal.market.sender.DingtalkSender
|
||||||
import jakarta.annotation.Resource
|
import jakarta.annotation.Resource
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.springframework.data.domain.Sort
|
||||||
import org.springframework.scheduling.annotation.Scheduled
|
import org.springframework.scheduling.annotation.Scheduled
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@@ -16,12 +17,12 @@ class PushRunner : Runner {
|
|||||||
|
|
||||||
@Scheduled(cron = "0 30 9,12,15,18,21 * * ?")
|
@Scheduled(cron = "0 30 9,12,15,18,21 * * ?")
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val articles = articleRepository.findAll { root, _, builder ->
|
val articles = articleRepository.findAll({ root, _, builder ->
|
||||||
builder.or(
|
builder.or(
|
||||||
builder.equal(root.get<Boolean>("pushed"), false),
|
builder.equal(root.get<Boolean>("pushed"), false),
|
||||||
builder.isNull(root.get<Boolean>("pushed")),
|
builder.isNull(root.get<Boolean>("pushed")),
|
||||||
)
|
)
|
||||||
}
|
}, Sort.by(Sort.Direction.DESC, "createTime"))
|
||||||
try {
|
try {
|
||||||
DingtalkSender().send("近期要闻", mapOf("articles" to articles.take(10)))
|
DingtalkSender().send("近期要闻", mapOf("articles" to articles.take(10)))
|
||||||
articles.forEach { articleRepository.updatePushedById(it.id, true) }
|
articles.forEach { articleRepository.updatePushedById(it.id, true) }
|
||||||
|
|||||||
Reference in New Issue
Block a user