Skip to content

Commit

Permalink
refactor: add totalPage field to PageResult
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiinaKin committed Oct 20, 2024
1 parent 5e470a1 commit f15bcaa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/kotlin/io/sakurasou/controller/vo/CommonVO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class PageResult<T>(
val page: Long,
val pageSize: Int,
val total: Long,
val totalPage: Long,
val data: List<T>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface PaginationDao {
val offset = (page - 1) * pageSize

val totalRecords: Long = customWhereCond(table.selectAll()).count()
val totalPage: Long = (totalRecords + pageSize - 1) / pageSize
val query = table.selectAll().limit(pageSize).offset(offset)

pageRequest.orderBy?.let {
Expand All @@ -42,6 +43,7 @@ interface PaginationDao {
page = page,
pageSize = pageSize,
total = totalRecords,
totalPage = totalPage,
data = data
)
return pageResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class UserDaoImpl : UserDao {
page = page,
pageSize = pageSize,
total = totalRecords,
totalPage = (totalRecords + pageSize - 1) / pageSize,
data = data
)
return pageResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class StrategyServiceImpl(
page = strategyPageResult.page,
pageSize = strategyPageResult.pageSize,
total = strategyPageResult.total,
totalPage = strategyPageResult.totalPage,
data = pageVOList
)
}
Expand Down

0 comments on commit f15bcaa

Please sign in to comment.