Add sort to GatPage interface

This commit is contained in:
Alexander Buntakov 2022-03-17 13:03:47 +03:00
parent a144f06bb8
commit be1d99da35
1 changed files with 9 additions and 2 deletions

View File

@ -2,11 +2,18 @@ package ru.touchin.common.spring.jpa.converters
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Pageable
import org.springframework.data.domain.Sort
import ru.touchin.common.page.GetPage
fun GetPage.toPageable(): Pageable {
return PageRequest.of(
fun GetPage.toPageable(sort: Sort? = null): Pageable {
val pageRequest = PageRequest.of(
page - 1,
size,
)
if (sort != null) {
return pageRequest.withSort(sort)
}
return pageRequest
}