Extract default page and size
This commit is contained in:
@@ -6,6 +6,8 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import ltd.hlaeja.library.deviceRegistry.Devices
|
import ltd.hlaeja.library.deviceRegistry.Devices
|
||||||
import ltd.hlaeja.service.DeviceService
|
import ltd.hlaeja.service.DeviceService
|
||||||
|
import ltd.hlaeja.util.Pagination.DEFAULT_PAGE
|
||||||
|
import ltd.hlaeja.util.Pagination.DEFAULT_SIZE
|
||||||
import ltd.hlaeja.util.toDevicesResponse
|
import ltd.hlaeja.util.toDevicesResponse
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
@@ -16,11 +18,6 @@ class DevicesController(
|
|||||||
private val deviceService: DeviceService,
|
private val deviceService: DeviceService,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val DEFAULT_PAGE: Int = 1
|
|
||||||
const val DEFAULT_SIZE: Int = 25
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping(
|
@GetMapping(
|
||||||
"/devices",
|
"/devices",
|
||||||
"/devices/page-{page}",
|
"/devices/page-{page}",
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import ltd.hlaeja.library.deviceRegistry.Types
|
import ltd.hlaeja.library.deviceRegistry.Types
|
||||||
import ltd.hlaeja.service.TypeService
|
import ltd.hlaeja.service.TypeService
|
||||||
|
import ltd.hlaeja.util.Pagination.DEFAULT_PAGE
|
||||||
|
import ltd.hlaeja.util.Pagination.DEFAULT_SIZE
|
||||||
import ltd.hlaeja.util.toTypesResponse
|
import ltd.hlaeja.util.toTypesResponse
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
@@ -14,10 +16,6 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
class TypesController(
|
class TypesController(
|
||||||
private val service: TypeService,
|
private val service: TypeService,
|
||||||
) {
|
) {
|
||||||
companion object {
|
|
||||||
const val DEFAULT_PAGE: Int = 1
|
|
||||||
const val DEFAULT_SIZE: Int = 25
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping(
|
@GetMapping(
|
||||||
"/types",
|
"/types",
|
||||||
|
|||||||
6
src/main/kotlin/ltd/hlaeja/util/Pagination.kt
Normal file
6
src/main/kotlin/ltd/hlaeja/util/Pagination.kt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package ltd.hlaeja.util
|
||||||
|
|
||||||
|
object Pagination {
|
||||||
|
const val DEFAULT_PAGE: Int = 1
|
||||||
|
const val DEFAULT_SIZE: Int = 25
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user