forked from maiora/backend-api
Compare commits
No commits in common. "4c3ea7fbf0430b870e056b2e05e713798c8e2e10" and "3fe10dfcdb29b9160636dbcd2b40c026ab7058e8" have entirely different histories.
4c3ea7fbf0
...
3fe10dfcdb
@ -111,12 +111,6 @@ object ProdottiPrenotabiliTable : IdTable<Long>("view_prodotti_prenotabili"){
|
|||||||
val modalitaPrenotazione = varchar("modalita_prenotazione", 255)
|
val modalitaPrenotazione = varchar("modalita_prenotazione", 255)
|
||||||
}
|
}
|
||||||
|
|
||||||
object ResidenzeTable : IdTable<Long>("residenze"){
|
|
||||||
override val id = long("id").entityId()
|
|
||||||
val idPuntoDistribuzione = long("id_punto_distribuzione")
|
|
||||||
val nome = varchar("nome", 255)
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccountsDAO(id: EntityID<Int>) :IntEntity(id) {
|
class AccountsDAO(id: EntityID<Int>) :IntEntity(id) {
|
||||||
companion object : IntEntityClass<AccountsDAO>(AccountsTable)
|
companion object : IntEntityClass<AccountsDAO>(AccountsTable)
|
||||||
|
|
||||||
@ -214,13 +208,6 @@ class ProdottiPrenotabiliDao(id: EntityID<Long>) :LongEntity(id) {
|
|||||||
var modalitaPrenotazione by ProdottiPrenotabiliTable.modalitaPrenotazione
|
var modalitaPrenotazione by ProdottiPrenotabiliTable.modalitaPrenotazione
|
||||||
}
|
}
|
||||||
|
|
||||||
class ResidenzeDao(id: EntityID<Long>) :LongEntity(id){
|
|
||||||
companion object : LongEntityClass<ResidenzeDao>(ResidenzeTable)
|
|
||||||
|
|
||||||
val idPuntoDistribuzione by ResidenzeTable.idPuntoDistribuzione
|
|
||||||
val nome by ResidenzeTable.nome
|
|
||||||
}
|
|
||||||
|
|
||||||
fun accountsDaoToModel(dao: AccountsDAO) = Accounts(
|
fun accountsDaoToModel(dao: AccountsDAO) = Accounts(
|
||||||
dao.id.value,
|
dao.id.value,
|
||||||
dao.username,
|
dao.username,
|
||||||
@ -332,14 +319,6 @@ fun prodottiPrenotabiliDaoToModel(dao: ProdottiPrenotabiliDao) :ProdottiPrenotab
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun residenzeDaoToModel(dao: ResidenzeDao) :Residenze{
|
|
||||||
return Residenze(
|
|
||||||
dao.id.value,
|
|
||||||
dao.idPuntoDistribuzione,
|
|
||||||
dao.nome
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun <T> suspendTransaction(block: Transaction.() -> T): T =
|
suspend fun <T> suspendTransaction(block: Transaction.() -> T): T =
|
||||||
newSuspendedTransaction(Dispatchers.IO, statement = block)
|
newSuspendedTransaction(Dispatchers.IO, statement = block)
|
@ -1,10 +0,0 @@
|
|||||||
package eu.maiora.model
|
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Residenze(
|
|
||||||
val id: Long,
|
|
||||||
val idPuntoDistribuzione : Long,
|
|
||||||
val nome : String
|
|
||||||
)
|
|
@ -1,5 +0,0 @@
|
|||||||
package eu.maiora.model
|
|
||||||
|
|
||||||
interface ResidenzeRepository {
|
|
||||||
suspend fun listaResidenze(): List<Residenze>
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package eu.maiora.model
|
|
||||||
|
|
||||||
import eu.maiora.db.*
|
|
||||||
|
|
||||||
class ResidenzeRepositoryImpl : ResidenzeRepository {
|
|
||||||
override suspend fun listaResidenze(): List<Residenze> = suspendTransaction {
|
|
||||||
// Cerca la lista di composizioni
|
|
||||||
ResidenzeDao.all()
|
|
||||||
.toList()
|
|
||||||
.map { residenzeDaoToModel(it) } // Converte il DAO in un oggetto Residenze
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,6 +21,5 @@ fun Application.configureRouting() {
|
|||||||
puntiDistribuzione(PuntiDistribuzioneRepositoryImpl())
|
puntiDistribuzione(PuntiDistribuzioneRepositoryImpl())
|
||||||
slotOrari(SlotOrariRepositoryImpl())
|
slotOrari(SlotOrariRepositoryImpl())
|
||||||
prodottiPrenotabili(ProdottiPrenotabiliRepositoryImpl())
|
prodottiPrenotabili(ProdottiPrenotabiliRepositoryImpl())
|
||||||
residenze(ResidenzeRepositoryImpl())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package eu.maiora.routes
|
|
||||||
|
|
||||||
import eu.maiora.model.ResidenzeRepositoryImpl
|
|
||||||
import io.ktor.server.application.*
|
|
||||||
import io.ktor.server.auth.*
|
|
||||||
import io.ktor.server.response.*
|
|
||||||
import io.ktor.server.routing.*
|
|
||||||
|
|
||||||
|
|
||||||
fun Route.residenze(residenzeRepository: ResidenzeRepositoryImpl){
|
|
||||||
route("/api/residenze"){
|
|
||||||
authenticate("auth-jwt") {
|
|
||||||
get(){
|
|
||||||
val listaResidenze = residenzeRepository.listaResidenze()
|
|
||||||
call.respond(listaResidenze)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user