fixes of todos

This commit is contained in:
2020-08-26 11:32:11 +06:00
parent 01ab884e68
commit 83fd9f264a
6 changed files with 74 additions and 53 deletions

View File

@@ -1,11 +1,7 @@
package com.insanusmokrassar.postssystem.utils.repos.ktor.server
import com.insanusmokrassar.postssystem.ktor.server.extractPagination
import com.insanusmokrassar.postssystem.ktor.server.getQueryParameterOrSendError
import com.insanusmokrassar.postssystem.ktor.server.unianswer
import com.insanusmokrassar.postssystem.ktor.server.uniload
import com.insanusmokrassar.postssystem.ktor.server.*
import com.insanusmokrassar.postssystem.ktor.standardKtorSerialFormat
import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination
import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult
import com.insanusmokrassar.postssystem.utils.repos.OneToManyKeyValueRepo
import com.insanusmokrassar.postssystem.utils.repos.OneToManyReadKeyValueRepo
@@ -27,14 +23,14 @@ fun <Key, Value> Route.configureOneToManyReadKeyValueRepoRoutes(
get(getRoute) {
val pagination = call.request.queryParameters.extractPagination
val key = standardKtorSerialFormat.decodeFromHexString(
keySerializer,
call.getQueryParameterOrSendError(keyParameterName) ?: return@get
) // TODO: Леша, а это можно сократить как-то до call.decodeFromQueryHexParameter(keySerializer, keyParameterName)?
val reversed = standardKtorSerialFormat.decodeFromHexString(
Boolean.serializer(),
call.getQueryParameterOrSendError(reversedParameterName) ?: return@get
)
val key = call.uniloadFromQueryOrSendError(
keyParameterName,
keySerializer
) ?: return@get
val reversed = call.uniloadFromQuery(
reversedParameterName,
Boolean.serializer()
) ?: false
call.unianswer(
paginationValueResult,
@@ -44,10 +40,10 @@ fun <Key, Value> Route.configureOneToManyReadKeyValueRepoRoutes(
get(keysRoute) {
val pagination = call.request.queryParameters.extractPagination
val reversed = standardKtorSerialFormat.decodeFromHexString(
Boolean.serializer(),
call.getQueryParameterOrSendError(reversedParameterName) ?: return@get
)
val reversed = call.uniloadFromQuery(
reversedParameterName,
Boolean.serializer()
) ?: false
call.unianswer(
paginationKeyResult,
@@ -68,14 +64,14 @@ fun <Key, Value> Route.configureOneToManyReadKeyValueRepoRoutes(
}
get(containsByKeyValueRoute) {
val key = standardKtorSerialFormat.decodeFromHexString(
keySerializer,
call.getQueryParameterOrSendError(keyParameterName) ?: return@get
)
val value = standardKtorSerialFormat.decodeFromHexString(
valueSealizer,
call.getQueryParameterOrSendError(valueParameterName) ?: return@get
)
val key = call.uniloadFromQueryOrSendError(
keyParameterName,
keySerializer
) ?: return@get
val value = call.uniloadFromQueryOrSendError(
valueParameterName,
valueSealizer
) ?: return@get
call.unianswer(
Boolean.serializer(),
@@ -84,10 +80,10 @@ fun <Key, Value> Route.configureOneToManyReadKeyValueRepoRoutes(
}
get(countByKeyRoute) {
val key = standardKtorSerialFormat.decodeFromHexString(
keySerializer,
call.getQueryParameterOrSendError(keyParameterName) ?: return@get
)
val key = call.uniloadFromQueryOrSendError(
keyParameterName,
keySerializer
) ?: return@get
call.unianswer(
Long.serializer(),

View File

@@ -30,10 +30,10 @@ fun <ObjectType, IdType> Route.configureReadStandardCrudRepoRoutes(
}
get(getByIdRouting) {
val id = standardKtorSerialFormat.decodeFromHexString(
idsSerializer,
call.getQueryParameterOrSendError("id") ?: return@get
)
val id = call.uniloadFromQueryOrSendError(
"id",
idsSerializer
) ?: return@get
call.unianswer(
objectsNullableSerializer,
@@ -42,10 +42,10 @@ fun <ObjectType, IdType> Route.configureReadStandardCrudRepoRoutes(
}
get(containsRouting) {
val id = standardKtorSerialFormat.decodeFromHexString(
idsSerializer,
call.getQueryParameterOrSendError("id") ?: return@get
)
val id = call.uniloadFromQueryOrSendError(
"id",
idsSerializer
) ?: return@get
call.unianswer(
Boolean.serializer(),