add map type info in ktor read kv and crud repos

This commit is contained in:
InsanusMokrassar 2023-03-10 21:41:01 +06:00
parent 022297ad3f
commit f4c148bc58
3 changed files with 7 additions and 2 deletions

View File

@ -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>(

View File

@ -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
)

View File

@ -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
)