Clean the request process

Remove paginated
Remove Entity classes
Add Annotation for serialize object
rename selectOne/selectMultiple to execute
This commit is contained in:
2023-04-06 21:03:15 +02:00
parent 7d39dcf248
commit a7e66ab8b5
31 changed files with 380 additions and 1212 deletions

View File

@@ -2,116 +2,43 @@ package fr.postgresjson.connexion
import com.fasterxml.jackson.core.type.TypeReference
import com.github.jasync.sql.db.QueryResult
import fr.postgresjson.entity.EntityI
import kotlin.jvm.Throws
sealed interface EmbedExecutable {
sealed interface EmbedExecutable : Executable {
val connection: Connection
override fun toString(): String
val name: String
/* Select One */
/**
* Update [EntityI] with one entity as argument
* Select with unnamed parameters
*/
fun <R : EntityI> update(
typeReference: TypeReference<R>,
value: R,
block: SelectOneCallback<R> = {}
): R? =
selectOne(typeReference, listOf(value), block)
/**
* Select One [EntityI] with [List] of parameters
*/
fun <R : EntityI> selectOne(
@Throws(DataNotFoundException::class)
fun <R : Any> execute(
typeReference: TypeReference<R>,
values: List<Any?>,
block: SelectOneCallback<R> = {}
block: SelectCallback<R> = {}
): R?
/**
* Select One [EntityI] with [Map] of parameters
* Select with named parameters
*/
fun <R : EntityI> selectOne(
@Throws(DataNotFoundException::class)
fun <R : Any> execute(
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: SelectOneCallback<R> = {}
block: SelectCallback<R> = {}
): R?
/**
* Select One [EntityI] with multiple [Pair] of parameters
* Select with named parameters
*/
fun <R : EntityI> selectOne(
@Throws(DataNotFoundException::class)
fun <R : Any> execute(
typeReference: TypeReference<R>,
vararg values: Pair<String, Any?>,
block: SelectOneCallback<R> = {}
block: SelectCallback<R> = {}
): R? =
selectOne(typeReference, values.toMap(), block)
/* Select Multiples */
/**
* Select Multiple [EntityI] with [List] of parameters
*/
fun <R : EntityI> select(
typeReference: TypeReference<List<R>>,
values: List<Any?>,
block: SelectCallback<R> = {}
): List<R>
/**
* Select Multiple [EntityI] with [Map] of parameters
*/
fun <R : EntityI> select(
typeReference: TypeReference<List<R>>,
values: Map<String, Any?>,
block: SelectCallback<R> = {}
): List<R>
/**
* Select Multiple [EntityI] with multiple [Pair] of parameters
*/
fun <R : EntityI> select(
typeReference: TypeReference<List<R>>,
vararg values: Pair<String, Any?>,
block: SelectCallback<R> = {}
): List<R> =
select(typeReference, values.toMap(), block)
/**
* Select Multiple or One [EntityI] with multiple [Pair] of parameters
*/
fun <R : Any?> selectAny(
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: QueryResult.(R) -> Unit = {}
): R
/* Select Paginated */
/**
* Select Paginated [EntityI] with [Map] of parameters
*/
fun <R : EntityI> select(
page: Int,
limit: Int,
typeReference: TypeReference<List<R>>,
values: Map<String, Any?>,
block: SelectPaginatedCallback<R> = {}
): Paginated<R>
/**
* Select Paginated [EntityI] with multiple [Pair] of parameters
*/
fun <R : EntityI> select(
page: Int,
limit: Int,
typeReference: TypeReference<List<R>>,
vararg values: Pair<String, Any?>,
block: SelectPaginatedCallback<R> = {}
): Paginated<R> =
select(page, limit, typeReference, values.toMap(), block)
execute(typeReference, values.toMap(), block)
fun exec(values: List<Any?>): QueryResult
fun exec(values: Map<String, Any?>): QueryResult