diff --git a/common-spring-jpa/build.gradle.kts b/common-spring-jpa/build.gradle.kts index a5063a8..9ed5882 100644 --- a/common-spring-jpa/build.gradle.kts +++ b/common-spring-jpa/build.gradle.kts @@ -10,6 +10,7 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + implementation(project(":common")) implementation(project(":common-spring")) implementation("org.springframework.boot:spring-boot-starter-data-jpa") diff --git a/common-spring-jpa/src/main/kotlin/ru/touchin/common/spring/jpa/converters/GetPageConverter.kt b/common-spring-jpa/src/main/kotlin/ru/touchin/common/spring/jpa/converters/GetPageConverter.kt new file mode 100644 index 0000000..5f292d5 --- /dev/null +++ b/common-spring-jpa/src/main/kotlin/ru/touchin/common/spring/jpa/converters/GetPageConverter.kt @@ -0,0 +1,12 @@ +package ru.touchin.common.spring.jpa.converters + +import org.springframework.data.domain.PageRequest +import org.springframework.data.domain.Pageable +import ru.touchin.common.page.GetPage + +fun GetPage.toPageable(): Pageable { + return PageRequest.of( + page - 1, + size, + ) +} diff --git a/common/src/main/kotlin/ru/touchin/common/page/GetPage.kt b/common/src/main/kotlin/ru/touchin/common/page/GetPage.kt new file mode 100644 index 0000000..a76920a --- /dev/null +++ b/common/src/main/kotlin/ru/touchin/common/page/GetPage.kt @@ -0,0 +1,8 @@ +package ru.touchin.common.page + +interface GetPage { + + val page: Int + val size: Int + +} diff --git a/common/src/main/kotlin/ru/touchin/common/page/PageInfo.kt b/common/src/main/kotlin/ru/touchin/common/page/PageInfo.kt new file mode 100644 index 0000000..ac96d50 --- /dev/null +++ b/common/src/main/kotlin/ru/touchin/common/page/PageInfo.kt @@ -0,0 +1,8 @@ +package ru.touchin.common.page + +interface PageInfo { + + val pageCount: Int + val totalItemCount: Long + +}