Add sort to GatPage interface
This commit is contained in:
parent
a144f06bb8
commit
be1d99da35
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue