From c07a524d64116f69a92c38b9e49c95813f2ad216 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Sun, 22 Dec 2024 13:21:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lanyuanxiaoyao/bookstore/controller/ChapterController.kt | 2 +- .../lanyuanxiaoyao/bookstore/controller/LineController.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/ChapterController.kt b/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/ChapterController.kt index 26a9144..a62970f 100644 --- a/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/ChapterController.kt +++ b/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/ChapterController.kt @@ -44,7 +44,7 @@ class ChapterController { ): PageResponse { val pageable = chapterRepository.findAll({ root, _, builder -> builder.equal(root.get("book").get("bookId"), bookId) - }, PageRequest.of(0.coerceAtLeast(page - 1), size)) + }, PageRequest.of(0.coerceAtLeast(page - 1), size).withSort(Sort.by(Sort.Direction.ASC, "sequence"))) return PageResponse( pageable.content.map { ViewItem(it) }, pageable.totalElements, diff --git a/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/LineController.kt b/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/LineController.kt index f511a96..10eac0c 100644 --- a/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/LineController.kt +++ b/src/main/kotlin/com/lanyuanxiaoyao/bookstore/controller/LineController.kt @@ -10,6 +10,7 @@ import jakarta.annotation.Resource import jakarta.transaction.Transactional import org.slf4j.LoggerFactory import org.springframework.data.domain.PageRequest +import org.springframework.data.domain.Sort import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping @@ -33,11 +34,11 @@ class LineController { fun list( @PathVariable("chapterId") chapterId: String, @RequestParam("page", defaultValue = "1") page: Int, - @RequestParam("size", defaultValue = "10") size: Int + @RequestParam("size", defaultValue = "10") size: Int, ): PageResponse { val pageable = lineRepository.findAll({ root, _, builder -> builder.equal(root.get("chapter").get("chapterId"), chapterId) - }, PageRequest.of(0.coerceAtLeast(page - 1), size)) + }, PageRequest.of(0.coerceAtLeast(page - 1), size).withSort(Sort.by(Sort.Direction.ASC, "sequence"))) return PageResponse( pageable.content.map { ViewItem(it) }, pageable.totalElements,