Skip to content

Commit

Permalink
✨ :: page 1일때 조회 되게 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
louis7308 committed Aug 17, 2023
1 parent fd0c782 commit ee9cd70
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ class FindAllUseCase(
}

fun List<Student.StudentWithUserInfo>.toDomainPageWithUserInfo(page: Int, size: Int): Student.StudentWithPageInfo {
val startIndex = page * size
val startIndex = (page - 1) * size
val endIndex = (startIndex + size).coerceAtMost(this.size)
val content = this.subList(startIndex, endIndex)
val content = if (startIndex <= endIndex) this.subList(startIndex, endIndex) else emptyList()

val totalPages = (this.size + size - 1) / size
val isLast = page >= totalPages - 1
val isLast = page >= totalPages

return Student.StudentWithPageInfo(
students = content,
page = page + 1,
page = page,
contentSize = content.size,
totalSize = this.size.toLong(),
last = isLast
Expand Down

0 comments on commit ee9cd70

Please sign in to comment.