refactoring: move Query/Function logic into Requester class

This commit is contained in:
2019-06-14 17:09:52 +02:00
parent baa2976e80
commit 00d2fa335d
8 changed files with 235 additions and 160 deletions

View File

@@ -1,7 +1,7 @@
package fr.postgresjson.repository
import fr.postgresjson.Serializer
import fr.postgresjson.connexion.Connection
import fr.postgresjson.connexion.Requester
import fr.postgresjson.entity.EntityCollection
import fr.postgresjson.entity.EntityI
import kotlin.reflect.KClass
@@ -12,11 +12,11 @@ interface RepositoryI<T, E : EntityI<T?>> {
abstract class Repository<T, E : EntityI<T?>>(override val entityName: KClass<E>) : RepositoryI<T, E> {
abstract var connection: Connection
abstract var requester: Requester
abstract fun getClassName(): String
fun <T> findById(id: T): EntityI<T?>? {
val sql = this.connection.getQuery(entityName.toString())
val sql = requester.getQuery(entityName.toString())
return when (val e = EntityCollection().get(id)) {
null -> {
// TODO create Request