forked from maiora/backend-api
Compare commits
No commits in common. "e0e93f93d02f22ec67a8847faff85757b1d137d9" and "5ae17aa8a869c9ccd0c9a8b3d2a374bd94e520cd" have entirely different histories.
e0e93f93d0
...
5ae17aa8a8
@ -1,6 +1,9 @@
|
|||||||
package eu.maiora.db
|
package eu.maiora.db
|
||||||
|
|
||||||
import eu.maiora.model.*
|
import eu.maiora.model.Accounts
|
||||||
|
import eu.maiora.model.Movimenti
|
||||||
|
import eu.maiora.model.Parametri
|
||||||
|
import eu.maiora.model.Tessere
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import org.jetbrains.exposed.dao.IntEntity
|
import org.jetbrains.exposed.dao.IntEntity
|
||||||
import org.jetbrains.exposed.dao.IntEntityClass
|
import org.jetbrains.exposed.dao.IntEntityClass
|
||||||
@ -59,15 +62,6 @@ object MovimentiTable : IdTable<Long>("view_movimenti_api"){
|
|||||||
val puntiPost = integer("punti_post")
|
val puntiPost = integer("punti_post")
|
||||||
}
|
}
|
||||||
|
|
||||||
object ComposizioniTable : IdTable<Long>("view_composizioni"){
|
|
||||||
override val id = long("id").entityId()
|
|
||||||
val idVassoio = long("id_vassoio")
|
|
||||||
val vassoio = varchar("vassoio", 255)
|
|
||||||
val idCategoria = long("id_categoria")
|
|
||||||
val categoria = varchar("categoria", 255)
|
|
||||||
val quantita = integer("quantita")
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccountsDAO(id: EntityID<Int>) :IntEntity(id) {
|
class AccountsDAO(id: EntityID<Int>) :IntEntity(id) {
|
||||||
companion object : IntEntityClass<AccountsDAO>(AccountsTable)
|
companion object : IntEntityClass<AccountsDAO>(AccountsTable)
|
||||||
|
|
||||||
@ -110,16 +104,6 @@ class MovimentiDao(id: EntityID<Long>) :LongEntity(id) {
|
|||||||
var puntiPost by MovimentiTable.puntiPost
|
var puntiPost by MovimentiTable.puntiPost
|
||||||
}
|
}
|
||||||
|
|
||||||
class ComposizioniDao(id: EntityID<Long>) :LongEntity(id){
|
|
||||||
companion object : LongEntityClass<ComposizioniDao>(ComposizioniTable)
|
|
||||||
|
|
||||||
var idVassoio by ComposizioniTable.idVassoio
|
|
||||||
var vassoio by ComposizioniTable.vassoio
|
|
||||||
var idCategoria by ComposizioniTable.idCategoria
|
|
||||||
var categoria by ComposizioniTable.categoria
|
|
||||||
var quantita by ComposizioniTable.quantita
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun accountsDaoToModel(dao: AccountsDAO) = Accounts(
|
fun accountsDaoToModel(dao: AccountsDAO) = Accounts(
|
||||||
dao.id.value,
|
dao.id.value,
|
||||||
@ -164,15 +148,6 @@ fun movimentiDaoToModel(dao: MovimentiDao) :Movimenti{
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun composizioniDaoToModel(dao: ComposizioniDao) =Composizioni(
|
|
||||||
dao.id.value,
|
|
||||||
dao.idVassoio,
|
|
||||||
dao.vassoio,
|
|
||||||
dao.idCategoria,
|
|
||||||
dao.categoria,
|
|
||||||
dao.quantita
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package eu.maiora.model
|
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Composizioni(
|
|
||||||
val id: Long,
|
|
||||||
val idVassoio : Long,
|
|
||||||
val vassoio : String,
|
|
||||||
val idCategoria : Long,
|
|
||||||
val categoria : String,
|
|
||||||
val quantita : Int
|
|
||||||
)
|
|
@ -1,5 +0,0 @@
|
|||||||
package eu.maiora.model
|
|
||||||
|
|
||||||
interface ComposizioniRepository {
|
|
||||||
suspend fun listaComposizioni(): List<Composizioni>
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package eu.maiora.model
|
|
||||||
|
|
||||||
import eu.maiora.db.*
|
|
||||||
import org.jetbrains.exposed.sql.SortOrder
|
|
||||||
|
|
||||||
class ComposizioniRepositoryImpl : ComposizioniRepository {
|
|
||||||
override suspend fun listaComposizioni(): List<Composizioni> = suspendTransaction {
|
|
||||||
// Cerca la lista di composizioni
|
|
||||||
ComposizioniDao.all()
|
|
||||||
.toList()
|
|
||||||
.map { composizioniDaoToModel(it) } // Converte il DAO in un oggetto Composizioni
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,6 @@ package eu.maiora.plugins
|
|||||||
|
|
||||||
import eu.maiora.model.*
|
import eu.maiora.model.*
|
||||||
import eu.maiora.routes.auth
|
import eu.maiora.routes.auth
|
||||||
import eu.maiora.routes.composizioni
|
|
||||||
import eu.maiora.routes.movimenti
|
import eu.maiora.routes.movimenti
|
||||||
import eu.maiora.routes.tessere
|
import eu.maiora.routes.tessere
|
||||||
import eu.maiora.routes.valorePasti
|
import eu.maiora.routes.valorePasti
|
||||||
@ -19,7 +18,6 @@ fun Application.configureRouting() {
|
|||||||
auth(AccountsRepositoryImpl())
|
auth(AccountsRepositoryImpl())
|
||||||
tessere(TessereRepositoryImpl())
|
tessere(TessereRepositoryImpl())
|
||||||
movimenti(MovimentiRepositoryImpl())
|
movimenti(MovimentiRepositoryImpl())
|
||||||
composizioni(ComposizioniRepositoryImpl())
|
|
||||||
valorePasti(ValorePastiRepositoryImpl())
|
valorePasti(ValorePastiRepositoryImpl())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package eu.maiora.routes
|
|
||||||
|
|
||||||
import eu.maiora.model.ComposizioniRepositoryImpl
|
|
||||||
import io.ktor.server.application.*
|
|
||||||
import io.ktor.server.auth.*
|
|
||||||
import io.ktor.server.response.*
|
|
||||||
import io.ktor.server.routing.*
|
|
||||||
|
|
||||||
|
|
||||||
fun Route.composizioni(composizioniRepository: ComposizioniRepositoryImpl){
|
|
||||||
route("/api/composizioni"){
|
|
||||||
authenticate("auth-jwt") {
|
|
||||||
get(){
|
|
||||||
val listaComposizioni = composizioniRepository.listaComposizioni()
|
|
||||||
call.respond(listaComposizioni)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user