diff --git a/.gitignore b/.gitignore
index 0c42199..4adf277 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,4 +33,5 @@ build
*.sqlite
out/
database.svg
-*.bkp
\ No newline at end of file
+*.bkp
+*.dtmp
\ No newline at end of file
diff --git a/README.md b/README.md
index 2d15b24..88f88b6 100644
--- a/README.md
+++ b/README.md
@@ -50,28 +50,33 @@ The application host it's data in a SQLite database. The access is managed by an
---
-#### Validate
+#### Listing existing
-POST /accounts/login (Login for user)
+GET /events?city=cityName&genre=genreName (Get all events, filtered by city and genre)
+
##### Parameters
> | name | type | data type | description |
-> | --- | --- | --- | --- |
-> | username | required | string | Username of the account |
-> | password | required | string | Password of the account |
+> | :---: | --- | --- | --- |
+> | `cityName` | optional | string | Name of the city to filter for |
+> | `genreName` | optional | string | Name of the genre to filter for |
##### Responses
> | http code | content-type | response |
> | :---: | --- | --- |
-> | `200` | `application/json` | `AccountObject` + `Addresses`, `Payments`, `AccountRole` |
-> | `400` | `application/json` | `{code: 400, message: "Bad Request"}` |
-> | `401` | `application/json` | `{code: 401, message: "Unauthorized"}` |
+> | `200` | `application/json` | `Event` + `Array` + `Array` |
----
-#### Listing existing
+
+
+
+
+Down here: todo!
+
+
+
GET /bands (Get all bands)
@@ -319,4 +324,26 @@ The application host it's data in a SQLite database. The access is managed by an
> | http code | content-type | response |
> | :---: | --- | --- |
> | `200` | None | None |
-
\ No newline at end of file
+
+
+
+#### Validate
+
+
+POST /accounts/login (Login for user)
+
+##### Parameters
+> | name | type | data type | description |
+> | --- | --- | --- | --- |
+> | username | required | string | Username of the account |
+> | password | required | string | Password of the account |
+
+##### Responses
+> | http code | content-type | response |
+> | :---: | --- | --- |
+> | `200` | `application/json` | `AccountObject` + `Addresses`, `Payments`, `AccountRole` |
+> | `400` | `application/json` | `{code: 400, message: "Bad Request"}` |
+> | `401` | `application/json` | `{code: 401, message: "Unauthorized"}` |
+
+
+---
\ No newline at end of file
diff --git a/misc/database.drawio b/misc/database.drawio
index b9a059c..62b2020 100644
--- a/misc/database.drawio
+++ b/misc/database.drawio
@@ -1,10 +1,10 @@
-
+
-
+
-
+
@@ -116,7 +116,7 @@
-
+
@@ -151,7 +151,7 @@
-
+
@@ -252,7 +252,7 @@
-
+
@@ -270,9 +270,6 @@
-
-
-
@@ -382,7 +379,7 @@
-
+
@@ -586,7 +583,7 @@
-
+
@@ -622,7 +619,7 @@
-
+
@@ -668,34 +665,34 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -705,17 +702,17 @@
-
+
-
+
-
+
@@ -725,55 +722,55 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -783,37 +780,82 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/software/backend/data/tours.json b/software/backend/data/events.json
similarity index 79%
rename from software/backend/data/tours.json
rename to software/backend/data/events.json
index 4320f38..d8d1998 100644
--- a/software/backend/data/tours.json
+++ b/software/backend/data/events.json
@@ -12,40 +12,35 @@
"date": "2024-10-18",
"price": 92,
"inStock": 0,
- "locationId": 0,
- "tourId": 0
+ "locationId": 0
},
{
"id": 1,
"date": "2024-10-19",
"price": 92,
"inStock": 170,
- "locationId": 0,
- "tourId": 0
+ "locationId": 0
},
{
"id": 2,
"date": "2024-10-23",
"price": 119.90,
"inStock": 8736,
- "locationId": 4,
- "tourId": 0
+ "locationId": 4
},
{
"id": 3,
"date": "2024-10-26",
"price": 114.90,
"inStock": 2793,
- "locationId": 8,
- "tourId": 0
+ "locationId": 8
},
{
"id": 4,
"date": "2024-11-02",
"price": 124.90,
"inStock": 3079,
- "locationId": 12,
- "tourId": 0
+ "locationId": 12
}
]
},
@@ -61,24 +56,21 @@
"date": "2024-11-30",
"price": 108,
"inStock": 1200,
- "locationId": 1,
- "tourId": 1
+ "locationId": 1
},
{
"id": 6,
"date": "2024-12-01",
"price": 104,
"inStock": 1800,
- "locationId": 5,
- "tourId": 1
+ "locationId": 5
},
{
"id": 7,
"date": "2024-12-07",
"price": 99.90,
"inStock": 2438,
- "locationId": 9,
- "tourId": 1
+ "locationId": 9
}
]
},
@@ -94,16 +86,14 @@
"date": "2025-01-21",
"price": 67.90,
"inStock": 994,
- "locationId": 3,
- "tourId": 2
+ "locationId": 3
},
{
"id": 9,
"date": "2024-11-15",
"price": 79.90,
"inStock": 1073,
- "locationId": 14,
- "tourId": 2
+ "locationId": 14
}
]
},
@@ -119,24 +109,21 @@
"date": "2024-12-07",
"price": 124.90,
"inStock": 765,
- "locationId": 13,
- "tourId": 3
+ "locationId": 13
},
{
"id": 11,
"date": "2025-01-17",
"price": 129.90,
"inStock": 989,
- "locationId": 9,
- "tourId": 3
+ "locationId": 9
},
{
"id": 12,
"date": "2025-02-01",
"price": 134.90,
"inStock": 827,
- "locationId": 4,
- "tourId": 3
+ "locationId": 4
}
]
},
@@ -152,8 +139,7 @@
"date": "2024-12-05",
"price": 80,
"inStock": 99,
- "locationId": 2,
- "tourId": 4
+ "locationId": 2
}
]
},
@@ -169,16 +155,14 @@
"date": "2025-01-12",
"price": 81.90,
"inStock": 173,
- "locationId": 2,
- "tourId": 5
+ "locationId": 2
},
{
"id": 15,
"date": "2025-02-01",
"price": 84.90,
"inStock": 192,
- "locationId": 6,
- "tourId": 5
+ "locationId": 6
}
]
},
@@ -194,16 +178,14 @@
"date": "2025-02-27",
"price": 67.90,
"inStock": 847,
- "locationId": 3,
- "tourId": 6
+ "locationId": 3
},
{
"id": 17,
"date": "2025-03-06",
"price": 64.90,
"inStock": 245,
- "locationId": 9,
- "tourId": 6
+ "locationId": 9
}
]
},
@@ -219,32 +201,28 @@
"date": "2025-01-15",
"price": 67.90,
"inStock": 847,
- "locationId": 2,
- "tourId": 7
+ "locationId": 2
},
{
"id": 19,
"date": "2025-01-23",
"price": 64.90,
"inStock": 245,
- "locationId": 10,
- "tourId": 7
+ "locationId": 10
},
{
"id": 20,
"date": "2025-02-02",
"price": 64.90,
"inStock": 245,
- "locationId": 13,
- "tourId": 7
+ "locationId": 13
},
{
"id": 21,
"date": "2025-02-05",
"price": 64.90,
"inStock": 245,
- "locationId": 13,
- "tourId": 7
+ "locationId": 13
}
]
}
diff --git a/software/backend/data/orderItems.json b/software/backend/data/orderItems.json
deleted file mode 100644
index 612ce53..0000000
--- a/software/backend/data/orderItems.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "data": [
- {
- "id": 0,
- "orderId": 0,
- "showId": 0,
- "quantity": 2,
- "orderPrice": 184
- }
- ]
-}
\ No newline at end of file
diff --git a/software/backend/data/orders.json b/software/backend/data/orders.json
index 35b2766..4ba1c15 100644
--- a/software/backend/data/orders.json
+++ b/software/backend/data/orders.json
@@ -5,21 +5,43 @@
"accountId": 0,
"shippingProgress": 4,
"addressId": 0,
- "paymentId": 0
+ "paymentId": 0,
+ "tickets": [
+ {
+ "concertId": 0,
+ "orderPrice": 184
+ }
+ ]
},
{
"id": 1,
"accountId": 3,
"shippingProgress": 5,
"addressId": 4,
- "paymentId": 3
+ "paymentId": 3,
+ "tickets": [
+ {
+ "concertId": 0,
+ "orderPrice": 184
+ },
+ {
+ "concertId": 0,
+ "orderPrice": 184
+ }
+ ]
},
{
"id": 2,
"accountId": 3,
"shippingProgress": 2,
"addressId": 5,
- "paymentId": 3
+ "paymentId": 3,
+ "tickets": [
+ {
+ "concertId": 0,
+ "orderPrice": 184
+ }
+ ]
}
]
}
\ No newline at end of file
diff --git a/software/backend/database.ts b/software/backend/database.ts
index 95caa03..cc5b00a 100644
--- a/software/backend/database.ts
+++ b/software/backend/database.ts
@@ -2,7 +2,7 @@ import { Sequelize } from "sequelize-typescript"
// Models
import { Order } from "./models/ordering/order.model"
-import { OrderItem } from "./models/ordering/orderItem.model"
+import { Ticket } from "./models/ordering/ticket.model"
import { Account } from "./models/user/account.model"
import { prepopulateDatabase } from "./scripts/databaseHelper"
import { Address } from "./models/user/address.model"
@@ -14,7 +14,7 @@ import { Band } from "./models/acts/band.model"
import { Concert } from "./models/acts/concert.model"
import { Member } from "./models/acts/member.model"
import { Rating } from "./models/acts/rating.model"
-import { Tour } from "./models/acts/tour.model"
+import { Event } from "./models/acts/event.model"
import { City } from "./models/locations/city.model"
import { BandGenre } from "./models/acts/bandGenre.model"
import { Seat } from "./models/locations/seat.model"
@@ -35,18 +35,23 @@ export const sequelize = new Sequelize({
models: [
AccountRole, Account, Payment, Address,
City, Location, SeatGroup, SeatRow, Seat,
- Genre, Band, BandGenre, Rating, Member, Tour, Concert,
- Order, OrderItem
+ Genre, Band, BandGenre, Rating, Member, Event, Concert,
+ Order, Ticket
]
})
export function startDatabase() {
+ let force = false
+
// Create database and tables
- sequelize.sync({ force: true })
+ sequelize.sync({ force: force })
.then(() => {
console.log("Database & tables created!")
- prepopulateDatabase()
+ if (force) {
+ prepopulateDatabase()
+ }
+
console.log("Database prepopulated!")
})
}
diff --git a/software/backend/models/acts/band.model.ts b/software/backend/models/acts/band.model.ts
index dddcc9f..112c4d4 100644
--- a/software/backend/models/acts/band.model.ts
+++ b/software/backend/models/acts/band.model.ts
@@ -2,7 +2,7 @@ import { BelongsTo, BelongsToMany, Column, DataType, ForeignKey, HasMany, Model,
import { Member } from "./member.model";
import { Genre } from "./genre.model";
import { Rating } from "./rating.model";
-import { Tour } from "./tour.model";
+import { Event } from "./event.model";
import { BandGenre } from "./bandGenre.model";
@Table({ timestamps: false })
@@ -45,8 +45,8 @@ export class Band extends Model {
@HasMany(() => Rating)
ratings: Rating[]
- @HasMany(() => Tour)
- tours: Tour[]
+ @HasMany(() => Event)
+ events: Event[]
@BelongsToMany(() => Genre, () => BandGenre)
genres: Genre[]
diff --git a/software/backend/models/acts/concert.model.ts b/software/backend/models/acts/concert.model.ts
index 3d75188..26852fb 100644
--- a/software/backend/models/acts/concert.model.ts
+++ b/software/backend/models/acts/concert.model.ts
@@ -1,7 +1,7 @@
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
import { Location } from "./../locations/location.model";
-import { Tour } from "./tour.model";
-import { OrderItem } from "../ordering/orderItem.model";
+import { Event } from "./event.model";
+import { Ticket } from "../ordering/ticket.model";
@Table({ timestamps: false })
export class Concert extends Model {
@@ -18,18 +18,19 @@ export class Concert extends Model {
@Column
locationId: Number
- @ForeignKey(() => Tour)
- tourId: Number
+ @ForeignKey(() => Event)
+ @Column
+ eventId: Number
// Relations
- @BelongsTo(() => Tour)
- tour: Tour
+ @BelongsTo(() => Event)
+ event: Event
@BelongsTo(() => Location)
location: Location
- @HasMany(() => OrderItem)
- orderItems: OrderItem[]
+ @HasMany(() => Ticket)
+ tickets: Ticket[]
}
\ No newline at end of file
diff --git a/software/backend/models/acts/tour.model.ts b/software/backend/models/acts/event.model.ts
similarity index 92%
rename from software/backend/models/acts/tour.model.ts
rename to software/backend/models/acts/event.model.ts
index e1eec93..837356c 100644
--- a/software/backend/models/acts/tour.model.ts
+++ b/software/backend/models/acts/event.model.ts
@@ -3,7 +3,7 @@ import { Band } from "./band.model";
import { Concert } from "./concert.model";
@Table({ timestamps: false })
-export class Tour extends Model {
+export class Event extends Model {
@Column
name: String
diff --git a/software/backend/models/ordering/order.model.ts b/software/backend/models/ordering/order.model.ts
index e5577fe..47b8c95 100644
--- a/software/backend/models/ordering/order.model.ts
+++ b/software/backend/models/ordering/order.model.ts
@@ -1,6 +1,6 @@
import { Table, Column, Model, BelongsTo, ForeignKey, HasMany, BelongsToMany, Default } from 'sequelize-typescript';
import { Account } from '../user/account.model';
-import { OrderItem } from './orderItem.model';
+import { Ticket } from './ticket.model';
import { Address } from '../user/address.model';
import { Payment } from '../user/payment.model';
@@ -40,6 +40,6 @@ export class Order extends Model {
@BelongsTo(() => Payment)
payment: Payment
- @HasMany(() => OrderItem)
- orderItems: OrderItem[]
+ @HasMany(() => Ticket)
+ tickets: Ticket[]
}
diff --git a/software/backend/models/ordering/orderItem.model.ts b/software/backend/models/ordering/ticket.model.ts
similarity index 71%
rename from software/backend/models/ordering/orderItem.model.ts
rename to software/backend/models/ordering/ticket.model.ts
index bb51ad6..6ae9b60 100644
--- a/software/backend/models/ordering/orderItem.model.ts
+++ b/software/backend/models/ordering/ticket.model.ts
@@ -1,22 +1,24 @@
import { Model, BelongsTo, Column, ForeignKey, HasMany, HasOne, Table } from "sequelize-typescript";
import { Concert } from "../acts/concert.model";
import { Order } from "./order.model";
+import { Seat } from "../locations/seat.model";
@Table({ timestamps: false })
-export class OrderItem extends Model {
+export class Ticket extends Model {
@Column
@ForeignKey(() => Order)
orderId: number
- @Column
- quantity: number
-
@Column
orderPrice: number
@Column
@ForeignKey(() => Concert)
- showId: number
+ concertId: number
+
+ @Column
+ @ForeignKey(() => Seat)
+ seatId: number
// Relations
@@ -25,4 +27,7 @@ export class OrderItem extends Model {
@BelongsTo(() => Concert)
product: Concert
+
+ @BelongsTo(() => Seat)
+ seat: Seat
}
diff --git a/software/backend/routes/band.routes.ts b/software/backend/routes/band.routes.ts
index 6b509fa..a1f3beb 100644
--- a/software/backend/routes/band.routes.ts
+++ b/software/backend/routes/band.routes.ts
@@ -3,7 +3,7 @@ import { Band } from "../models/acts/band.model";
import { Request, Response, Router } from "express";
import { Rating } from "../models/acts/rating.model";
import { Genre } from "../models/acts/genre.model";
-import { Tour } from "../models/acts/tour.model";
+import { Event } from "../models/acts/event.model";
import { Concert } from "../models/acts/concert.model";
import { Location } from "../models/locations/location.model";
import { City } from "../models/locations/city.model";
@@ -27,7 +27,7 @@ band.get("/", (req: Request, res: Response) => {
}
},
{
- model: Tour,
+ model: Event,
include: [
{
model: Concert,
diff --git a/software/backend/routes/concert.routes.ts b/software/backend/routes/concert.routes.ts
index b75ee32..b2fc846 100644
--- a/software/backend/routes/concert.routes.ts
+++ b/software/backend/routes/concert.routes.ts
@@ -1,7 +1,7 @@
import { Location } from "../models/locations/location.model";
import { Concert } from "../models/acts/concert.model";
import { Request, Response, Router } from "express";
-import { Tour } from "../models/acts/tour.model";
+import { Event } from "../models/acts/event.model";
import { City } from "../models/locations/city.model";
export const concert = Router()
@@ -9,7 +9,7 @@ export const concert = Router()
concert.get("/:id", (req: Request, res: Response) => {
Concert.findByPk(req.params.id, {
include: [
- Tour,
+ Event,
{
model: Location,
include: [ City ],
diff --git a/software/backend/routes/events.routes.ts b/software/backend/routes/events.routes.ts
new file mode 100644
index 0000000..b84ece1
--- /dev/null
+++ b/software/backend/routes/events.routes.ts
@@ -0,0 +1,79 @@
+import { Concert } from "../models/acts/concert.model";
+import { Band } from "../models/acts/band.model";
+import { Event } from "../models/acts/event.model";
+import { Request, Response, Router } from "express";
+import { Location } from "../models/locations/location.model";
+import { Genre } from "../models/acts/genre.model";
+import { City } from "../models/locations/city.model";
+
+export const events = Router()
+
+events.get("/", async (req: Request, res: Response) => {
+ let cityName = req.query.city
+ let genreName = req.query.genre
+ let cityFilter = {}
+ let genreFilter = {}
+
+ if (cityName != undefined) {
+ cityFilter = {
+ model: City,
+ where: { name: cityName }
+ }
+ } else {
+ cityFilter = {
+ model: City
+ }
+ }
+
+
+ if (genreName != undefined) {
+ genreFilter = {
+ model: Genre,
+ where: { name: genreName }
+ }
+ } else {
+ genreFilter = {
+ model: Genre
+ }
+ }
+
+ Event.findAll({
+ include: [
+ {
+ model: Concert,
+ include: [
+ {
+ model: Location,
+ include: [
+ cityFilter
+ ]
+ }
+ ]
+ },
+ {
+ model: Band,
+ include: [
+ genreFilter
+ ]
+ }
+ ]
+ })
+ .then(events => {
+ let resultArray = []
+
+ // Remove datasets which not fulfill the optional parameter
+ for (let event of events) {
+ if (event.dataValues.band != null) {
+ for (let concert of event.dataValues.concerts) {
+ if (concert.dataValues.location != null) {
+ resultArray.push(event)
+ break
+ }
+ }
+ }
+ }
+
+ res.status(200).json(resultArray)
+ })
+
+})
\ No newline at end of file
diff --git a/software/backend/routes/location.routes.ts b/software/backend/routes/location.routes.ts
index 97b0926..1f3b510 100644
--- a/software/backend/routes/location.routes.ts
+++ b/software/backend/routes/location.routes.ts
@@ -2,7 +2,7 @@ import { Concert } from "../models/acts/concert.model";
import { City } from "../models/locations/city.model";
import { Location } from "../models/locations/location.model";
import { Request, Response, Router } from "express";
-import { Tour } from "../models/acts/tour.model";
+import { Event } from "../models/acts/event.model";
import { Band } from "../models/acts/band.model";
import { SeatGroup } from "../models/locations/seatGroup.model";
import { Seat } from "../models/locations/seat.model";
@@ -16,7 +16,7 @@ location.get("/", (req: Request, res: Response) => {
City,
{
model: Concert,
- include: [ Tour ],
+ include: [ Event ],
attributes: {
exclude: [ "locationId", "tourId" ]
}
diff --git a/software/backend/routes/order.routes.ts b/software/backend/routes/order.routes.ts
index 588fb69..1808562 100644
--- a/software/backend/routes/order.routes.ts
+++ b/software/backend/routes/order.routes.ts
@@ -1,7 +1,7 @@
import { Router, Request, Response } from "express";
import { Order } from "../models/ordering/order.model";
import { Concert } from "../models/acts/concert.model";
-import { OrderItem } from "../models/ordering/orderItem.model";
+import { Ticket } from "../models/ordering/ticket.model";
import { Payment } from "../models/user/payment.model";
import { Address } from "../models/user/address.model";
import { Band } from "../models/acts/band.model";
@@ -15,7 +15,7 @@ order.get("/:id", (req: Request, res: Response) => {
where: { accountId: req.params.id },
include: [
{
- model: OrderItem,
+ model: Ticket,
include: [
{
model: Concert,
@@ -43,7 +43,7 @@ order.post("/", (req: Request, res: Response) => {
Order.create(req.body)
.then(async order => {
for (let orderItem of req.body.orderItems) {
- OrderItem.create({
+ Ticket.create({
orderId: order.id,
quantity: orderItem.quantity,
orderPrice: orderItem.orderPrice,
diff --git a/software/backend/routes/tour.routes.ts b/software/backend/routes/tour.routes.ts
deleted file mode 100644
index 0f3e47e..0000000
--- a/software/backend/routes/tour.routes.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { Concert } from "../models/acts/concert.model";
-import { Band } from "../models/acts/band.model";
-import { Tour } from "../models/acts/tour.model";
-import { Request, Response, Router } from "express";
-import { Location } from "../models/locations/location.model";
-import { Genre } from "../models/acts/genre.model";
-import { City } from "../models/locations/city.model";
-
-export const tour = Router()
-
-tour.get("/", (req: Request, res: Response) => {
- Tour.findAll({
- include: [
- {
- model: Band,
- include: [ Genre ],
- attributes: {
- exclude: [ "genreId" ]
- }
- },
- {
- model: Concert,
- include: [
- {
- model: Location,
- include: [ City ],
- attributes: {
- exclude: [ "cityId" ]
- }
- }
- ],
- attributes: {
- exclude: [ "locationId", "tourId" ]
- }
- },
- ],
- attributes: {
- exclude: [ "bandId" ]
- }
- })
- .then(tours => {
- res.status(200).json(tours)
- })
-})
\ No newline at end of file
diff --git a/software/backend/scripts/databaseHelper.ts b/software/backend/scripts/databaseHelper.ts
index b0adbe0..64286e6 100644
--- a/software/backend/scripts/databaseHelper.ts
+++ b/software/backend/scripts/databaseHelper.ts
@@ -1,5 +1,5 @@
import { Order } from '../models/ordering/order.model'
-import { OrderItem } from '../models/ordering/orderItem.model'
+import { Ticket } from '../models/ordering/ticket.model'
import { Account } from '../models/user/account.model'
import { Address } from '../models/user/address.model'
import { Payment } from '../models/user/payment.model'
@@ -10,7 +10,7 @@ import { Genre } from '../models/acts/genre.model'
import { Band } from '../models/acts/band.model'
import { Location } from '../models/locations/location.model'
import { Concert } from '../models/acts/concert.model'
-import { Tour } from '../models/acts/tour.model'
+import { Event } from '../models/acts/event.model'
import { City } from '../models/locations/city.model'
import { BandGenre } from '../models/acts/bandGenre.model'
import { SeatGroup } from '../models/locations/seatGroup.model'
@@ -19,11 +19,10 @@ import { SeatRow } from '../models/locations/seatRow.model'
import accounts from "./../data/accounts.json"
import orders from "./../data/orders.json"
-import orderItems from "./../data/orderItems.json"
import accountRoles from "./../data/accountRoles.json"
import bands from "./../data/bands.json"
import genres from "./../data/genres.json"
-import tours from "./../data/tours.json"
+import events from "./../data/events.json"
import cities from "./../data/cities.json"
@@ -31,14 +30,14 @@ import cities from "./../data/cities.json"
* Delete all datasets in every database table
*/
export function deleteAllTables() {
- OrderItem.destroy({truncate: true })
+ Ticket.destroy({truncate: true })
Order.destroy({ truncate: true })
Rating.destroy({ truncate: true })
Member.destroy({ truncate: true })
Genre.destroy({ truncate: true })
Band.destroy({ truncate: true })
- Tour.destroy({ truncate: true })
+ Event.destroy({ truncate: true })
Location.destroy({ truncate: true })
Concert.destroy({ truncate: true })
@@ -145,15 +144,25 @@ export async function prepopulateDatabase() {
}
- for (let tour of tours.data) {
- await Tour.create(tour)
+ for (let tour of events.data) {
+ await Event.create(tour)
.then(async dataset => {
for (let concert of tour.concerts) {
+ concert["eventId"] = dataset.id
+
await Concert.create(concert)
}
})
}
- Order.bulkCreate(orders.data)
- OrderItem.bulkCreate(orderItems.data)
+ for (let order of orders.data) {
+ await Order.create(order)
+ .then(async dataset => {
+ for (let ticket of order.tickets) {
+ ticket["orderId"] = dataset.id
+
+ await Ticket.create(ticket)
+ }
+ })
+ }
}
\ No newline at end of file
diff --git a/software/backend/server.ts b/software/backend/server.ts
index 4de4f5c..5cdc112 100644
--- a/software/backend/server.ts
+++ b/software/backend/server.ts
@@ -9,7 +9,7 @@ import { concert } from './routes/concert.routes'
import { band } from './routes/band.routes'
import { genre } from './routes/genre.routes'
import { location } from './routes/location.routes'
-import { tour } from './routes/tour.routes'
+import { events } from './routes/events.routes'
import { city } from './routes/city.routes'
const app = express()
@@ -35,13 +35,12 @@ app.use('/static', express.static(path.join(__dirname, 'images')))
// Routes
app.use("/api", api)
-app.use("/shows", concert)
+app.use("/events", events)
app.use("/bands", band)
-app.use("/genres", genre)
app.use("/locations", location)
+app.use("/genres", genre)
app.use("/orders", order)
app.use("/accounts", account)
-app.use("/tours", tour)
app.use("/cities", city)
diff --git a/software/src/data/api/eventApi.ts b/software/src/data/api/eventApi.ts
new file mode 100644
index 0000000..190041b
--- /dev/null
+++ b/software/src/data/api/eventApi.ts
@@ -0,0 +1,12 @@
+import axios from "axios"
+
+const BASE_URL = "http://localhost:3000/events"
+
+export async function fetchEvents(city: string = "", genre: string = "") {
+ let url = BASE_URL + "?"
+ url += (city.length > 0) ? "city=" + city : ""
+ url += (genre.length > 0) ? "genre=" + genre : ""
+
+ console.log(url)
+ return await axios.get(url)
+}
\ No newline at end of file
diff --git a/software/src/data/models/acts/eventModel.ts b/software/src/data/models/acts/eventModel.ts
new file mode 100644
index 0000000..03c8971
--- /dev/null
+++ b/software/src/data/models/acts/eventModel.ts
@@ -0,0 +1,11 @@
+import { BandModel } from "./bandModel"
+import { ConcertModel } from "./concertModel"
+
+export class EventModel {
+ id: number
+ name: string
+ offered: boolean
+ image: string
+ band: BandModel
+ concerts: Array
+}
\ No newline at end of file
diff --git a/software/src/data/models/acts/tourModel.ts b/software/src/data/models/acts/tourModel.ts
index 5a1102c..e55e4bd 100644
--- a/software/src/data/models/acts/tourModel.ts
+++ b/software/src/data/models/acts/tourModel.ts
@@ -1,6 +1,9 @@
import { BandModel } from "./bandModel"
import { ConcertModel } from "./concertModel"
+/**
+ * @deprecated Use EventModel!
+ */
export class TourModel {
id: number
name: string
diff --git a/software/src/data/stores/shoppingStore.ts b/software/src/data/stores/shoppingStore.ts
new file mode 100644
index 0000000..db8f507
--- /dev/null
+++ b/software/src/data/stores/shoppingStore.ts
@@ -0,0 +1,19 @@
+import { defineStore } from "pinia";
+import { ref } from "vue";
+import { EventModel } from "../models/acts/eventModel";
+import { fetchEvents } from "../api/eventApi";
+
+export const useShoppingStore = defineStore("shoppingStore", {
+ state: () => ({
+ events: ref>([])
+ }),
+
+ actions: {
+ getEvents(city: string = "", genre: string = "") {
+ fetchEvents(city, genre)
+ .then(result => {
+ this.events = result.data
+ })
+ }
+ }
+})
\ No newline at end of file
diff --git a/software/src/pages/shows/bandDetailPage/concertSection.vue b/software/src/pages/shows/bandDetailPage/concertSection.vue
index 8b7b4b0..c283df8 100644
--- a/software/src/pages/shows/bandDetailPage/concertSection.vue
+++ b/software/src/pages/shows/bandDetailPage/concertSection.vue
@@ -5,8 +5,12 @@ import sectionDivider from '@/components/sectionDivider.vue';
import cardWithLeftImage from '@/components/cardWithLeftImage.vue';
import outlinedButton from '@/components/outlinedButton.vue';
import { useRouter } from 'vue-router';
+import ticketOrderDialog from './ticketOrderDialog.vue';
+import { ref } from 'vue';
+import { ConcertModel } from '@/data/models/acts/concertModel';
const router = useRouter()
+const showDialog = ref(false)
defineProps({
band: {
@@ -14,6 +18,10 @@ defineProps({
required: true
}
})
+
+function openTicketOrderDialog(concert: ConcertModel) {
+ showDialog.value = true
+}
@@ -60,6 +68,7 @@ defineProps({
{{ $t('add') }}
@@ -75,4 +84,6 @@ defineProps({
+
+
\ No newline at end of file
diff --git a/software/src/pages/shows/bandDetailPage/ticketOrderDialog.vue b/software/src/pages/shows/bandDetailPage/ticketOrderDialog.vue
new file mode 100644
index 0000000..b002626
--- /dev/null
+++ b/software/src/pages/shows/bandDetailPage/ticketOrderDialog.vue
@@ -0,0 +1,15 @@
+
+
+
+
+ 123
+
+
\ No newline at end of file
diff --git a/software/src/pages/shows/eventsPage/index.vue b/software/src/pages/shows/eventsPage/index.vue
index 76336ec..02d3c81 100644
--- a/software/src/pages/shows/eventsPage/index.vue
+++ b/software/src/pages/shows/eventsPage/index.vue
@@ -1,12 +1,14 @@
@@ -22,8 +24,8 @@ const concertStore = useConcertStore()