add map type info in ktor read kv and crud repos

This commit is contained in:
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<ObjectType>>(),
typeInfo<PaginationResult<IdType>>(), typeInfo<PaginationResult<IdType>>(),
contentType, contentType,
typeInfo<Map<IdType, ObjectType>>(),
idSerializer idSerializer
), ),
KtorWriteCrudRepoClient<ObjectType, IdType, InputValue>( KtorWriteCrudRepoClient<ObjectType, IdType, InputValue>(

View File

@@ -22,6 +22,7 @@ class KtorReadCRUDRepoClient<ObjectType, IdType> (
private val paginationObjectType: TypeInfo, private val paginationObjectType: TypeInfo,
private val paginationIdType: TypeInfo, private val paginationIdType: TypeInfo,
private val contentType: ContentType, private val contentType: ContentType,
private val mapTypeInfo: TypeInfo,
private val idSerializer: suspend (IdType) -> String private val idSerializer: suspend (IdType) -> String
) : ReadCRUDRepo<ObjectType, IdType> { ) : ReadCRUDRepo<ObjectType, IdType> {
override suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType> = httpClient.get( override suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType> = httpClient.get(
@@ -66,7 +67,7 @@ class KtorReadCRUDRepoClient<ObjectType, IdType> (
) )
) { ) {
contentType(contentType) contentType(contentType)
}.body() }.body(mapTypeInfo)
override suspend fun count(): Long = httpClient.get( override suspend fun count(): Long = httpClient.get(
buildStandardUrl( buildStandardUrl(
@@ -90,6 +91,7 @@ inline fun <reified ObjectType, IdType> KtorReadCRUDRepoClient(
typeInfo<PaginationResult<ObjectType>>(), typeInfo<PaginationResult<ObjectType>>(),
typeInfo<PaginationResult<IdType>>(), typeInfo<PaginationResult<IdType>>(),
contentType, contentType,
typeInfo<Map<IdType, ObjectType>>(),
idSerializer idSerializer
) )

View File

@@ -23,6 +23,7 @@ class KtorReadKeyValueRepoClient<Key, Value>(
private val objectType: TypeInfo, private val objectType: TypeInfo,
private val paginationResultObjectsTypeInfo: TypeInfo, private val paginationResultObjectsTypeInfo: TypeInfo,
private val paginationResultIdsTypeInfo: TypeInfo, private val paginationResultIdsTypeInfo: TypeInfo,
private val mapKeyValueTypeInfo: TypeInfo,
private val idSerializer: suspend (Key) -> String, private val idSerializer: suspend (Key) -> String,
private val valueSerializer: suspend (Value) -> String private val valueSerializer: suspend (Value) -> String
) : ReadKeyValueRepo<Key, Value> { ) : ReadKeyValueRepo<Key, Value> {
@@ -55,7 +56,7 @@ class KtorReadKeyValueRepoClient<Key, Value>(
) )
) { ) {
contentType(contentType) contentType(contentType)
}.body() }.body(mapKeyValueTypeInfo)
override suspend fun values( override suspend fun values(
pagination: Pagination, pagination: Pagination,
@@ -112,6 +113,7 @@ inline fun <reified Key, reified Value> KtorReadKeyValueRepoClient(
typeInfo<Value>(), typeInfo<Value>(),
typeInfo<PaginationResult<Value>>(), typeInfo<PaginationResult<Value>>(),
typeInfo<PaginationResult<Key>>(), typeInfo<PaginationResult<Key>>(),
typeInfo<Map<Key, Value>>(),
idSerializer, idSerializer,
valueSerializer valueSerializer
) )