Clean the request process
Remove paginated Remove Entity classes Add Annotation for serialize object rename selectOne/selectMultiple to execute
This commit is contained in:
@@ -2,81 +2,40 @@ package fr.postgresjson.connexion
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference
|
||||
import com.github.jasync.sql.db.QueryResult
|
||||
import fr.postgresjson.entity.EntityI
|
||||
|
||||
class Query(override val name: String, private val sql: String, override val connection: Connection) : EmbedExecutable {
|
||||
override fun toString(): String {
|
||||
return sql
|
||||
}
|
||||
|
||||
/* Select One */
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with [List] of parameters
|
||||
* Select with unnamed of parameters
|
||||
*/
|
||||
override fun <R : EntityI> selectOne(
|
||||
override fun <R : Any> execute(
|
||||
typeReference: TypeReference<R>,
|
||||
values: List<Any?>,
|
||||
block: SelectOneCallback<R>
|
||||
block: SelectCallback<R>
|
||||
): R? =
|
||||
connection.selectOne(sql, typeReference, values, block)
|
||||
connection.execute(sql, typeReference, values, block)
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with named parameters
|
||||
* Select with named parameters
|
||||
*/
|
||||
override fun <R : EntityI> selectOne(
|
||||
override fun <R : Any> execute(
|
||||
typeReference: TypeReference<R>,
|
||||
values: Map<String, Any?>,
|
||||
block: SelectOneCallback<R>
|
||||
block: SelectCallback<R>
|
||||
): R? =
|
||||
connection.selectOne(sql, typeReference, values, block)
|
||||
|
||||
/* Select Multiples */
|
||||
connection.execute(sql, typeReference, values, block)
|
||||
|
||||
/**
|
||||
* Select multiple [EntityI] with [List] of parameters
|
||||
* Execute function without treatments
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: List<Any?>,
|
||||
block: SelectCallback<R>
|
||||
): List<R> =
|
||||
connection.select(sql, typeReference, values, block)
|
||||
|
||||
/**
|
||||
* Select multiple [EntityI] with [Map] of parameters
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: Map<String, Any?>,
|
||||
block: SelectCallback<R>
|
||||
): List<R> =
|
||||
connection.select(sql, typeReference, values, block)
|
||||
|
||||
/* Select Paginated */
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with pagination
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: Map<String, Any?>,
|
||||
block: (QueryResult, Paginated<R>) -> Unit
|
||||
): Paginated<R> =
|
||||
connection.select(sql, page, limit, typeReference, values, block)
|
||||
|
||||
override fun <R> selectAny(
|
||||
typeReference: TypeReference<R>,
|
||||
values: Map<String, Any?>,
|
||||
block: QueryResult.(R) -> Unit
|
||||
): R = connection.selectAny(sql, typeReference, values.toMap(), block)
|
||||
|
||||
/* Execute function without treatments */
|
||||
|
||||
override fun exec(values: List<Any?>): QueryResult = connection.exec(sql, values)
|
||||
|
||||
/**
|
||||
* Execute function without treatments
|
||||
*/
|
||||
override fun exec(values: Map<String, Any?>): QueryResult = connection.exec(sql, values)
|
||||
|
||||
/**
|
||||
@@ -88,6 +47,7 @@ class Query(override val name: String, private val sql: String, override val con
|
||||
* Warning: this method not use prepared statement
|
||||
*/
|
||||
fun sendQuery(values: Map<String, Any?>): QueryResult = connection.sendQuery(sql, values)
|
||||
|
||||
/**
|
||||
* Warning: this method not use prepared statement
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user