mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 16:23:50 +00:00
add map type info in ktor read kv and crud repos
This commit is contained in:
parent
022297ad3f
commit
f4c148bc58
@ -44,6 +44,7 @@ class KtorCRUDRepoClient<ObjectType, IdType, InputValue> (
|
||||
typeInfo<PaginationResult<ObjectType>>(),
|
||||
typeInfo<PaginationResult<IdType>>(),
|
||||
contentType,
|
||||
typeInfo<Map<IdType, ObjectType>>(),
|
||||
idSerializer
|
||||
),
|
||||
KtorWriteCrudRepoClient<ObjectType, IdType, InputValue>(
|
||||
|
@ -22,6 +22,7 @@ class KtorReadCRUDRepoClient<ObjectType, IdType> (
|
||||
private val paginationObjectType: TypeInfo,
|
||||
private val paginationIdType: TypeInfo,
|
||||
private val contentType: ContentType,
|
||||
private val mapTypeInfo: TypeInfo,
|
||||
private val idSerializer: suspend (IdType) -> String
|
||||
) : ReadCRUDRepo<ObjectType, IdType> {
|
||||
override suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType> = httpClient.get(
|
||||
@ -66,7 +67,7 @@ class KtorReadCRUDRepoClient<ObjectType, IdType> (
|
||||
)
|
||||
) {
|
||||
contentType(contentType)
|
||||
}.body()
|
||||
}.body(mapTypeInfo)
|
||||
|
||||
override suspend fun count(): Long = httpClient.get(
|
||||
buildStandardUrl(
|
||||
@ -90,6 +91,7 @@ inline fun <reified ObjectType, IdType> KtorReadCRUDRepoClient(
|
||||
typeInfo<PaginationResult<ObjectType>>(),
|
||||
typeInfo<PaginationResult<IdType>>(),
|
||||
contentType,
|
||||
typeInfo<Map<IdType, ObjectType>>(),
|
||||
idSerializer
|
||||
)
|
||||
|
||||
|
@ -23,6 +23,7 @@ class KtorReadKeyValueRepoClient<Key, Value>(
|
||||
private val objectType: TypeInfo,
|
||||
private val paginationResultObjectsTypeInfo: TypeInfo,
|
||||
private val paginationResultIdsTypeInfo: TypeInfo,
|
||||
private val mapKeyValueTypeInfo: TypeInfo,
|
||||
private val idSerializer: suspend (Key) -> String,
|
||||
private val valueSerializer: suspend (Value) -> String
|
||||
) : ReadKeyValueRepo<Key, Value> {
|
||||
@ -55,7 +56,7 @@ class KtorReadKeyValueRepoClient<Key, Value>(
|
||||
)
|
||||
) {
|
||||
contentType(contentType)
|
||||
}.body()
|
||||
}.body(mapKeyValueTypeInfo)
|
||||
|
||||
override suspend fun values(
|
||||
pagination: Pagination,
|
||||
@ -112,6 +113,7 @@ inline fun <reified Key, reified Value> KtorReadKeyValueRepoClient(
|
||||
typeInfo<Value>(),
|
||||
typeInfo<PaginationResult<Value>>(),
|
||||
typeInfo<PaginationResult<Key>>(),
|
||||
typeInfo<Map<Key, Value>>(),
|
||||
idSerializer,
|
||||
valueSerializer
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user