mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-11-26 17:25:52 +00:00
getAll
This commit is contained in:
@@ -5,6 +5,7 @@ import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||
import dev.inmo.micro_utils.repos.ktor.common.getAllRoute
|
||||
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.body
|
||||
@@ -58,6 +59,15 @@ class KtorReadCRUDRepoClient<ObjectType, IdType> (
|
||||
contentType(contentType)
|
||||
}.body()
|
||||
|
||||
override suspend fun getAll(): Map<IdType, ObjectType> = httpClient.get(
|
||||
buildStandardUrl(
|
||||
baseUrl,
|
||||
getAllRoute
|
||||
)
|
||||
) {
|
||||
contentType(contentType)
|
||||
}.body()
|
||||
|
||||
override suspend fun count(): Long = httpClient.get(
|
||||
buildStandardUrl(
|
||||
baseUrl,
|
||||
|
||||
@@ -48,6 +48,15 @@ class KtorReadKeyValueRepoClient<Key, Value>(
|
||||
contentType(contentType)
|
||||
}.body()
|
||||
|
||||
override suspend fun getAll(): Map<Key, Value> = httpClient.get(
|
||||
buildStandardUrl(
|
||||
baseUrl,
|
||||
getAllRoute
|
||||
)
|
||||
) {
|
||||
contentType(contentType)
|
||||
}.body()
|
||||
|
||||
override suspend fun values(
|
||||
pagination: Pagination,
|
||||
reversed: Boolean
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package dev.inmo.micro_utils.repos.ktor.common
|
||||
|
||||
const val getAllRoute = "getAll"
|
||||
@@ -6,6 +6,7 @@ import dev.inmo.micro_utils.pagination.extractPagination
|
||||
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||
import dev.inmo.micro_utils.repos.ktor.common.countRouting
|
||||
import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
||||
import dev.inmo.micro_utils.repos.ktor.common.getAllRoute
|
||||
import dev.inmo.micro_utils.repos.ktor.common.idParameterName
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.call
|
||||
@@ -53,6 +54,10 @@ inline fun <reified ObjectType, reified IdType> Route.configureReadCRUDRepoRoute
|
||||
)
|
||||
}
|
||||
|
||||
get(getAllRoute) {
|
||||
call.respond(originalRepo.getAll())
|
||||
}
|
||||
|
||||
get(countRouting) {
|
||||
call.respond(
|
||||
originalRepo.count()
|
||||
|
||||
@@ -70,6 +70,10 @@ inline fun <reified Key, reified Value> Route.configureReadKeyValueRepoRoutes (
|
||||
call.respond(originalRepo.contains(key))
|
||||
}
|
||||
|
||||
get(getAllRoute) {
|
||||
call.respond(originalRepo.getAll())
|
||||
}
|
||||
|
||||
get(countRoute) {
|
||||
call.respond(originalRepo.count())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user