diff --git a/misc/database.drawio b/misc/database.drawio index 62b2020..23307db 100644 --- a/misc/database.drawio +++ b/misc/database.drawio @@ -1,6 +1,6 @@ - + @@ -811,51 +811,57 @@ - + - + - + - + - + - + - + - + + + + + + + diff --git a/software/backend/data/orders.json b/software/backend/data/orders.json index 4ba1c15..3b76df9 100644 --- a/software/backend/data/orders.json +++ b/software/backend/data/orders.json @@ -9,7 +9,8 @@ "tickets": [ { "concertId": 0, - "orderPrice": 184 + "orderPrice": 184, + "seatId": 43 } ] }, diff --git a/software/backend/models/locations/seat.model.ts b/software/backend/models/locations/seat.model.ts index 53e7108..eb106da 100644 --- a/software/backend/models/locations/seat.model.ts +++ b/software/backend/models/locations/seat.model.ts @@ -1,5 +1,6 @@ -import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript"; +import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript"; import { SeatRow } from "./seatRow.model"; +import { Ticket } from "../ordering/ticket.model"; @Table({ timestamps: false }) export class Seat extends Model { @@ -15,4 +16,7 @@ export class Seat extends Model { @BelongsTo(() => SeatRow) seatRow: SeatRow + + @HasMany(() => Ticket) + tickets: Ticket[] } \ No newline at end of file diff --git a/software/backend/routes/band.routes.ts b/software/backend/routes/band.routes.ts index 4b0018b..f7add46 100644 --- a/software/backend/routes/band.routes.ts +++ b/software/backend/routes/band.routes.ts @@ -92,12 +92,12 @@ band.get("/:name", (req: Request, res: Response) => { } ], attributes: { - exclude: [ "id", "tourId", "locationId" ] + exclude: [ "tourId", "locationId" ] } } ], attributes: { - exclude: [ "id", "bandId" ] + exclude: [ "bandId" ] } }, Genre diff --git a/software/backend/routes/concert.routes.ts b/software/backend/routes/concert.routes.ts index b2fc846..32cbc01 100644 --- a/software/backend/routes/concert.routes.ts +++ b/software/backend/routes/concert.routes.ts @@ -3,6 +3,10 @@ import { Concert } from "../models/acts/concert.model"; import { Request, Response, Router } from "express"; import { Event } from "../models/acts/event.model"; import { City } from "../models/locations/city.model"; +import { SeatGroup } from "../models/locations/seatGroup.model"; +import { SeatRow } from "../models/locations/seatRow.model"; +import { Seat } from "../models/locations/seat.model"; +import { Ticket } from "../models/ordering/ticket.model"; export const concert = Router() @@ -12,7 +16,29 @@ concert.get("/:id", (req: Request, res: Response) => { Event, { model: Location, - include: [ City ], + include: [ + { + model: City + }, + { + model: SeatGroup, + include: [ + { + model: SeatRow, + include: [ + { + model: Seat, + include: [ + { + model: Ticket + } + ] + } + ] + } + ] + } + ], attributes: { exclude: [ "cityId" ] } @@ -22,7 +48,27 @@ concert.get("/:id", (req: Request, res: Response) => { exclude: [ "locationId", "tourId" ] } }) - .then(shows => { - res.status(200).json(shows) + .then(concert => { + for (let seatGroup of concert.dataValues.location.dataValues.seatGroups) { + seatGroup.dataValues["occupied"] = 0 + + for (let seatRow of seatGroup.dataValues.seatRows) { + for (let seat of seatRow.dataValues.seats) { + seat.dataValues["state"] = 0 + + for (let ticket of seat.dataValues.tickets) { + if (ticket.dataValues.concertId == req.params.id) { + seat.dataValues["state"] = 1 + seatGroup.dataValues["occupied"] += 1 + break + } + } + + delete seat.dataValues.tickets + } + } + } + + res.status(200).json(concert) }) -}) \ No newline at end of file +}) diff --git a/software/backend/server.ts b/software/backend/server.ts index e9d4eaa..d0b3bdc 100644 --- a/software/backend/server.ts +++ b/software/backend/server.ts @@ -42,6 +42,7 @@ app.use("/genres", genre) app.use("/orders", order) app.use("/accounts", account) app.use("/cities", city) +app.use("/concerts", concert) // Start server diff --git a/software/src/components/actionDialog.vue b/software/src/components/actionDialog.vue index d56957b..5139820 100644 --- a/software/src/components/actionDialog.vue +++ b/software/src/components/actionDialog.vue @@ -20,7 +20,7 @@ defineProps({ diff --git a/software/src/components/seatPlanMap/seatGroupSheet.vue b/software/src/components/seatPlanMap/seatGroupSheet.vue index 8ff44db..b3b4655 100644 --- a/software/src/components/seatPlanMap/seatGroupSheet.vue +++ b/software/src/components/seatPlanMap/seatGroupSheet.vue @@ -1,42 +1,23 @@