Big refactoring and implement Function
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
package fr.postgresjson.repository
|
||||
|
||||
import com.github.jasync.sql.db.pool.ConnectionPool
|
||||
import com.github.jasync.sql.db.postgresql.PostgreSQLConnection
|
||||
import fr.postgresjson.Serializer
|
||||
import fr.postgresjson.connexion.Connection
|
||||
import fr.postgresjson.entity.EntityCollection
|
||||
import fr.postgresjson.entity.EntityI
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
interface RepositoryI<T, E : EntityI<T>>
|
||||
interface RepositoryI<T, E : EntityI<T?>> {
|
||||
val entityName: KClass<E>
|
||||
}
|
||||
|
||||
abstract class Repository<T, E : EntityI<T>> : RepositoryI<T, E> {
|
||||
abstract var connection: ConnectionPool<PostgreSQLConnection>
|
||||
abstract class Repository<T, E : EntityI<T?>>(override val entityName: KClass<E>) : RepositoryI<T, E> {
|
||||
|
||||
abstract var connection: Connection
|
||||
abstract fun getClassName(): String
|
||||
|
||||
fun <T> findById(id: T): EntityI<T?>? {
|
||||
val sql = this.connection.getQuery(entityName.toString())
|
||||
return when (val e = EntityCollection().get(id)) {
|
||||
null -> {
|
||||
// TODO create Request
|
||||
@@ -20,4 +25,4 @@ abstract class Repository<T, E : EntityI<T>> : RepositoryI<T, E> {
|
||||
else -> e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user