Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,35 @@ import org.springframework.data.domain.Page
)
data class ReadingRecordsWithPrimaryEmotionResponse private constructor(
@field:Schema(description = "해당 책의 대표(최다) 감정")
val primaryEmotion: PrimaryEmotionDto?,
val representativeEmotion: PrimaryEmotionDto?,

@field:Schema(description = "독서 기록 목록 (페이징)")
val records: Page<ReadingRecordResponseV2>
@field:Schema(description = "마지막 페이지 여부", example = "false")
val lastPage: Boolean,

@field:Schema(description = "총 결과 개수", example = "42")
val totalResults: Int,

@field:Schema(description = "현재 페이지 번호 (0부터 시작)", example = "0")
val startIndex: Int,

@field:Schema(description = "한 페이지당 아이템 개수", example = "10")
val itemsPerPage: Int,

@field:Schema(description = "독서 기록 목록")
val readingRecords: List<ReadingRecordResponseV2>
) {
companion object {
fun of(
primaryEmotion: PrimaryEmotionDto?,
records: Page<ReadingRecordResponseV2>
representativeEmotion: PrimaryEmotionDto?,
page: Page<ReadingRecordResponseV2>
): ReadingRecordsWithPrimaryEmotionResponse {
return ReadingRecordsWithPrimaryEmotionResponse(
primaryEmotion = primaryEmotion,
records = records
representativeEmotion = representativeEmotion,
lastPage = page.isLast,
totalResults = page.totalElements.toInt(),
startIndex = page.number,
itemsPerPage = page.size,
readingRecords = page.content
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class ReadingRecordServiceV2(
val readingRecordPage = readingRecordDomainService.findByDynamicCondition(userBookId, sort, pageable)
if (readingRecordPage.isEmpty) {
return ReadingRecordsWithPrimaryEmotionResponse.of(
primaryEmotion = primaryEmotionDto,
records = Page.empty(pageable)
representativeEmotion = primaryEmotionDto,
page = Page.empty(pageable)
)
}

Expand All @@ -94,8 +94,8 @@ class ReadingRecordServiceV2(
val recordsPage = toResponsePage(readingRecordPage, detailTagsMap)

return ReadingRecordsWithPrimaryEmotionResponse.of(
primaryEmotion = primaryEmotionDto,
records = recordsPage
representativeEmotion = primaryEmotionDto,
page = recordsPage
)
}

Expand Down