Skip to content

Commit 13142b0

Browse files
committed
refactor: apis - 기본정렬과 동적정렬 UPDATE시간으로도 가능하도록 수정 (#125)
1 parent 185623e commit 13142b0

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

apis/src/main/kotlin/org/yapp/apis/book/controller/BookControllerApi.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ interface BookControllerApi {
158158
@RequestParam(required = false) @Parameter(description = "책 상태 필터") status: BookStatus?,
159159
@RequestParam(required = false) @Parameter(description = "정렬 방식") sort: UserBookSortType?,
160160
@RequestParam(required = false) @Parameter(description = "책 제목 검색") title: String?,
161-
@PageableDefault(size = 10, sort = ["createdAt"], direction = Sort.Direction.DESC)
161+
@Parameter(
162+
description = "페이징 정보 (기본값: 10개, 최신 수정일 순)",
163+
example = "?page=0&size=10&sort=updatedAt,desc"
164+
)
165+
@PageableDefault(size = 10, sort = ["updatedAt"], direction = Sort.Direction.DESC)
162166
pageable: Pageable
163167
): ResponseEntity<UserBookPageResponse>
164168

apis/src/main/kotlin/org/yapp/apis/readingrecord/controller/ReadingRecordControllerApi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ interface ReadingRecordControllerApi {
105105
@AuthenticationPrincipal @Parameter(description = "인증된 사용자 ID") userId: UUID,
106106
@PathVariable @Parameter(description = "독서 기록을 조회할 사용자 책 ID") userBookId: UUID,
107107
@RequestParam(required = false) @Parameter(description = "정렬 방식 (PAGE_NUMBER_ASC, PAGE_NUMBER_DESC, CREATED_DATE_ASC, CREATED_DATE_DESC)") sort: ReadingRecordSortType?,
108-
@PageableDefault(size = 10, sort = ["createdAt"], direction = Sort.Direction.DESC)
109-
@Parameter(description = "페이지네이션 정보 (페이지 번호, 페이지 크기, 정렬 방식)") pageable: Pageable
108+
@PageableDefault(size = 10, sort = ["updatedAt"], direction = Sort.Direction.DESC)
109+
@Parameter(description = "페이지네이션 정보 (기본값: 10개, 최신 수정일 순)") pageable: Pageable
110110
): ResponseEntity<ReadingRecordPageResponse>
111111

112112
@Operation(

domain/src/main/kotlin/org/yapp/domain/userbook/UserBookSortType.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ enum class UserBookSortType {
55
TITLE_ASC,
66
TITLE_DESC,
77
CREATED_DATE_ASC,
8-
CREATED_DATE_DESC;
8+
CREATED_DATE_DESC,
9+
UPDATED_DATE_ASC,
10+
UPDATED_DATE_DESC;
911
}

infra/src/main/kotlin/org/yapp/infra/userbook/repository/impl/JpaUserBookQuerydslRepositoryImpl.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ class JpaUserBookQuerydslRepositoryImpl(
164164
UserBookSortType.TITLE_DESC -> userBook.title.desc()
165165
UserBookSortType.CREATED_DATE_ASC -> userBook.createdAt.asc()
166166
UserBookSortType.CREATED_DATE_DESC -> userBook.createdAt.desc()
167-
null -> userBook.createdAt.desc()
167+
UserBookSortType.UPDATED_DATE_ASC -> userBook.updatedAt.asc()
168+
UserBookSortType.UPDATED_DATE_DESC -> userBook.updatedAt.desc()
169+
null -> userBook.updatedAt.desc()
168170
}
169171
}
170172
}

0 commit comments

Comments
 (0)