Compare commits

..

2 Commits

Author SHA1 Message Date
4c31ccd021 Backend documentation 2024-12-30 23:13:41 +01:00
57d35a01ba Bugfix search page (Band) 2024-12-21 21:05:06 +01:00
8 changed files with 1724 additions and 374 deletions

View File

@@ -12,9 +12,6 @@ export class AccountRole extends Model {
@Column @Column
privilegeAdminPanel: boolean privilegeAdminPanel: boolean
@Column
privilegeFileAccess: boolean
// Relations // Relations
@HasMany(() => Account) @HasMany(() => Account)

View File

@@ -103,7 +103,7 @@ band.get("/", (req: Request, res: Response) => {
/** /**
* Get all information about one band * Get all information about one band
*/ */
band.get("/:name", (req: Request, res: Response) => { band.get("/band/:name", (req: Request, res: Response) => {
Band.findOne({ Band.findOne({
where: { where: {
name: { [Op.like]: req.params.name } name: { [Op.like]: req.params.name }

View File

@@ -17,18 +17,68 @@ import { Op } from "sequelize";
export const concert = Router() export const concert = Router()
const concertStructure = [
{
model: Band
},
{
model: Location,
include: [
{
model: City
},
{
model: SeatGroup,
include: [
{
model: SeatRow,
include: [
{
model: Seat,
include: [
{
model: Ticket
}
]
}
]
}
]
}
],
attributes: {
exclude: [ "cityId" ]
}
}
]
/**
* @swagger
* /concerts:
* get:
* summary: Get all available concerts
* tags: [Concerts]
* parameters:
* - in: query
* name: count
* schema:
* type: number
* required: false
* description: Limit number of results
* responses:
* 200:
* description: OK
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/concert'
*/
concert.get("/", (req: Request, res: Response) => { concert.get("/", (req: Request, res: Response) => {
let count = req.query.count let count = req.query.count
Concert.findAll({ Concert.findAll({
include: [ include: concertStructure,
{
model: Location,
include: [ City ]
},
Band
],
order: [ order: [
[ 'date', 'ASC' ] [ 'date', 'ASC' ]
] ]
@@ -47,47 +97,31 @@ concert.get("/", (req: Request, res: Response) => {
}) })
// Get all available data about a band by it's ID /**
* @swagger
* /concerts/concert/{id}:
* get:
* summary: Download all available informations about a specific concert
* tags: [Concerts]
* parameters:
* - in: path
* name: id
* schema:
* type: number
* required: true
* description: ID of concert in database
* responses:
* 200:
* description: Single concert object
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/concert'
* 404:
* description: Not found
*/
concert.get("/concert/:id", (req: Request, res: Response) => { concert.get("/concert/:id", (req: Request, res: Response) => {
Concert.findByPk(req.params.id, { Concert.findByPk(req.params.id, { include: concertStructure })
include: [
{
model: Band,
},
{
model: Location,
include: [
{
model: City
},
{
model: SeatGroup,
include: [
{
model: SeatRow,
include: [
{
model: Seat,
include: [
{
model: Ticket
}
]
}
]
}
]
}
],
attributes: {
exclude: [ "cityId" ]
}
}
],
attributes: {
exclude: [ "locationId", "tourId" ]
}
})
.then(concert => { .then(concert => {
concert.dataValues["capacity"] = 0 concert.dataValues["capacity"] = 0
@@ -125,7 +159,29 @@ concert.get("/concert/:id", (req: Request, res: Response) => {
}) })
// Concert search /**
* @swagger
* /concerts/search:
* get:
* summary: Search for concerts
* tags: [Concerts]
* parameters:
* - in: query
* name: value
* schema:
* type: string
* required: true
* description: Search term
* responses:
* 200:
* description: List of concert objects
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/concert'
* 500:
* description: Internal server error
*/
concert.get("/search", (req: Request, res: Response) => { concert.get("/search", (req: Request, res: Response) => {
Concert.findAll({ Concert.findAll({
where: { where: {

View File

@@ -113,7 +113,7 @@ location.get("/", (req: Request, res: Response) => {
* description: Url name of the location to request for * description: Url name of the location to request for
* responses: * responses:
* 200: * 200:
* description: List of band objects * description: Single of location objects
* content: * content:
* application/json: * application/json:
* schema: * schema:

View File

@@ -129,8 +129,6 @@ order.get("/", verifyToken, (req: Request, res: Response) => {
order.post("/", verifyToken, (req: Request, res: Response) => { order.post("/", verifyToken, (req: Request, res: Response) => {
req.body["accountId"] = req["id"] req.body["accountId"] = req["id"]
console.log(req.body)
Order.create(req.body) Order.create(req.body)
.then(async order => { .then(async order => {
for (let ticket of req.body.tickets) { for (let ticket of req.body.tickets) {
@@ -158,6 +156,30 @@ order.post("/", verifyToken, (req: Request, res: Response) => {
}) })
}) })
/**
* @swagger
* /orders:
* patch:
* summary: Update an order
* tags: [Orders]
* parameters:
* - in: body
* name: order
* schema:
* type: object
* required: true
* description: Updated order object
* responses:
* 200:
* description: OK
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/order'
* 500:
* description: Internal server error
*/
order.patch("/", (req: Request, res: Response) => { order.patch("/", (req: Request, res: Response) => {
Order.update(req.body, { Order.update(req.body, {
where: { where: {

View File

@@ -162,291 +162,60 @@
"description": "Bands with this genre object" "description": "Bands with this genre object"
} }
}, },
"example": { "example": [
"id": 849, {
"urlName": "palladium", "id": 562,
"name": "Palladium", "name": "Funk Rock",
"address": "Schanzenstraße 40", "bands": [
"imageIndoor": "http://localhost:3000/static/locations/palladium-indoor.jpg", {
"imageOutdoor": "http://localhost:3000/static/locations/palladium-outdoor.jpg", "images": [
"layout": 1, "http://localhost:3000/static/bands/red-hot-chili-peppers-1.jpg",
"capacity": 50, "http://localhost:3000/static/bands/red-hot-chili-peppers-2.jpg",
"city": { "http://localhost:3000/static/bands/red-hot-chili-peppers-3.jpg",
"id": 250, "http://localhost:3000/static/bands/red-hot-chili-peppers-4.jpg"
"name": "Köln", ],
"country": "Germany" "id": 265,
}, "name": "Red Hot Chili Peppers",
"seatGroups": [ "foundingYear": 1983,
{ "descriptionEn": "The Red Hot Chili Peppers are an American rock band formed in Los Angeles in 1983, comprising vocalist Anthony Kiedis, bassist Flea, drummer Chad Smith, and guitarist John Frusciante. Their music incorporates elements of alternative rock, funk, punk rock, hard rock, hip hop, and psychedelic rock. Their eclectic range has influenced genres such as funk metal, rap metal, rap rock, and nu metal. With over 120 million records sold worldwide, the Red Hot Chili Peppers are one of the top-selling bands of all time.",
"id": 3949, "descriptionDe": "Red Hot Chili Peppers (Abkürzung: RHCP) ist eine 1983 gegründete US-amerikanische Funk- und Alternative-Rockband. Sie zählt zu den kommerziell erfolgreichsten Vertretern des Crossover. Ihr Album Blood Sugar Sex Magik gilt als eines der bedeutendsten dieses Genres.",
"name": "A", "imageMembers": "http://localhost:3000/static/bands/red-hot-chili-peppers-members.jpg",
"surcharge": 30, "logo": "http://localhost:3000/static/bands/red-hot-chili-peppers-logo.png",
"capacity": 50, "BandGenre": {
"standingArea": true, "id": 793,
"locationId": 849, "genreId": 562,
"seatRows": [ "bandId": 265
{
"id": 14999,
"row": 0,
"seatGroupId": 3949,
"seats": [
{
"id": 108411,
"seatNr": 1,
"seatRowId": 14999
},
{
"id": 108412,
"seatNr": 2,
"seatRowId": 14999
},
{
"id": 108413,
"seatNr": 3,
"seatRowId": 14999
},
{
"id": 108414,
"seatNr": 4,
"seatRowId": 14999
},
{
"id": 108415,
"seatNr": 5,
"seatRowId": 14999
},
{
"id": 108416,
"seatNr": 6,
"seatRowId": 14999
},
{
"id": 108417,
"seatNr": 7,
"seatRowId": 14999
},
{
"id": 108418,
"seatNr": 8,
"seatRowId": 14999
},
{
"id": 108419,
"seatNr": 9,
"seatRowId": 14999
},
{
"id": 108420,
"seatNr": 10,
"seatRowId": 14999
},
{
"id": 108421,
"seatNr": 11,
"seatRowId": 14999
},
{
"id": 108422,
"seatNr": 12,
"seatRowId": 14999
},
{
"id": 108423,
"seatNr": 13,
"seatRowId": 14999
},
{
"id": 108424,
"seatNr": 14,
"seatRowId": 14999
},
{
"id": 108425,
"seatNr": 15,
"seatRowId": 14999
},
{
"id": 108426,
"seatNr": 16,
"seatRowId": 14999
},
{
"id": 108427,
"seatNr": 17,
"seatRowId": 14999
},
{
"id": 108428,
"seatNr": 18,
"seatRowId": 14999
},
{
"id": 108429,
"seatNr": 19,
"seatRowId": 14999
},
{
"id": 108430,
"seatNr": 20,
"seatRowId": 14999
},
{
"id": 108431,
"seatNr": 21,
"seatRowId": 14999
},
{
"id": 108432,
"seatNr": 22,
"seatRowId": 14999
},
{
"id": 108433,
"seatNr": 23,
"seatRowId": 14999
},
{
"id": 108434,
"seatNr": 24,
"seatRowId": 14999
},
{
"id": 108435,
"seatNr": 25,
"seatRowId": 14999
},
{
"id": 108436,
"seatNr": 26,
"seatRowId": 14999
},
{
"id": 108437,
"seatNr": 27,
"seatRowId": 14999
},
{
"id": 108438,
"seatNr": 28,
"seatRowId": 14999
},
{
"id": 108439,
"seatNr": 29,
"seatRowId": 14999
},
{
"id": 108440,
"seatNr": 30,
"seatRowId": 14999
},
{
"id": 108441,
"seatNr": 31,
"seatRowId": 14999
},
{
"id": 108442,
"seatNr": 32,
"seatRowId": 14999
},
{
"id": 108443,
"seatNr": 33,
"seatRowId": 14999
},
{
"id": 108444,
"seatNr": 34,
"seatRowId": 14999
},
{
"id": 108445,
"seatNr": 35,
"seatRowId": 14999
},
{
"id": 108446,
"seatNr": 36,
"seatRowId": 14999
},
{
"id": 108447,
"seatNr": 37,
"seatRowId": 14999
},
{
"id": 108448,
"seatNr": 38,
"seatRowId": 14999
},
{
"id": 108449,
"seatNr": 39,
"seatRowId": 14999
},
{
"id": 108450,
"seatNr": 40,
"seatRowId": 14999
},
{
"id": 108451,
"seatNr": 41,
"seatRowId": 14999
},
{
"id": 108452,
"seatNr": 42,
"seatRowId": 14999
},
{
"id": 108453,
"seatNr": 43,
"seatRowId": 14999
},
{
"id": 108454,
"seatNr": 44,
"seatRowId": 14999
},
{
"id": 108455,
"seatNr": 45,
"seatRowId": 14999
},
{
"id": 108456,
"seatNr": 46,
"seatRowId": 14999
},
{
"id": 108457,
"seatNr": 47,
"seatRowId": 14999
},
{
"id": 108458,
"seatNr": 48,
"seatRowId": 14999
},
{
"id": 108459,
"seatNr": 49,
"seatRowId": 14999
},
{
"id": 108460,
"seatNr": 50,
"seatRowId": 14999
}
]
} }
] }
} ]
], },
"nrOfConcerts": 0 {
} "id": 563,
"name": "Alternative Rock",
"bands": [
{
"images": [
"http://localhost:3000/static/bands/red-hot-chili-peppers-1.jpg",
"http://localhost:3000/static/bands/red-hot-chili-peppers-2.jpg",
"http://localhost:3000/static/bands/red-hot-chili-peppers-3.jpg",
"http://localhost:3000/static/bands/red-hot-chili-peppers-4.jpg"
],
"id": 265,
"name": "Red Hot Chili Peppers",
"foundingYear": 1983,
"descriptionEn": "The Red Hot Chili Peppers are an American rock band formed in Los Angeles in 1983, comprising vocalist Anthony Kiedis, bassist Flea, drummer Chad Smith, and guitarist John Frusciante. Their music incorporates elements of alternative rock, funk, punk rock, hard rock, hip hop, and psychedelic rock. Their eclectic range has influenced genres such as funk metal, rap metal, rap rock, and nu metal. With over 120 million records sold worldwide, the Red Hot Chili Peppers are one of the top-selling bands of all time.",
"descriptionDe": "Red Hot Chili Peppers (Abkürzung: RHCP) ist eine 1983 gegründete US-amerikanische Funk- und Alternative-Rockband. Sie zählt zu den kommerziell erfolgreichsten Vertretern des Crossover. Ihr Album Blood Sugar Sex Magik gilt als eines der bedeutendsten dieses Genres.",
"imageMembers": "http://localhost:3000/static/bands/red-hot-chili-peppers-members.jpg",
"logo": "http://localhost:3000/static/bands/red-hot-chili-peppers-logo.png",
"BandGenre": {
"id": 794,
"genreId": 563,
"bandId": 265
}
}
]
}
]
}, },
"location": { "location": {
"type": "object", "type": "object",
@@ -679,8 +448,7 @@
"id": 1, "id": 1,
"name": "User", "name": "User",
"privilegeBuy": true, "privilegeBuy": true,
"privilegeAdminPanel": false, "privilegeAdminPanel": false
"privilegeFileAccess": null
}, },
"payments": [ "payments": [
{ {
@@ -759,8 +527,8 @@
} }
}, },
"example": { "example": {
"username": "artists", "name": "artists",
"password": 41 "description": 41
} }
}, },
"file": { "file": {
@@ -800,6 +568,91 @@
} }
} }
}, },
"concert": {
"type": "object",
"properties": {
"id": {
"type": "number",
"description": "The auto-generated id"
},
"date": {
"type": "string",
"description": "Date of the concert"
},
"name": {
"type": "string",
"description": "Name of concert"
},
"price": {
"type": "string",
"description": "Lowest price of concert"
},
"image": {
"type": "number",
"description": "Concert image"
},
"inStock": {
"type": "string",
"description": "Amount of available tickets"
},
"offered": {
"type": "string",
"description": "Display concert in UI"
},
"band": {
"type": "object",
"description": "Band object"
},
"location": {
"type": "object",
"description": "Location object"
}
},
"example": [
{
"id": 892,
"date": "2024-11-30",
"name": "Unlimited Love",
"price": 92,
"image": "http://localhost:3000/static/concerts/unlimited-love-tour.jpg",
"inStock": 169,
"offered": true,
"bandId": 265,
"locationId": 834,
"band": {
"images": [
"http://localhost:3000/static/bands/red-hot-chili-peppers-1.jpg",
"http://localhost:3000/static/bands/red-hot-chili-peppers-2.jpg",
"http://localhost:3000/static/bands/red-hot-chili-peppers-3.jpg",
"http://localhost:3000/static/bands/red-hot-chili-peppers-4.jpg"
],
"id": 265,
"name": "Red Hot Chili Peppers",
"foundingYear": 1983,
"descriptionEn": "The Red Hot Chili Peppers are an American rock band formed in Los Angeles in 1983, comprising vocalist Anthony Kiedis, bassist Flea, drummer Chad Smith, and guitarist John Frusciante. Their music incorporates elements of alternative rock, funk, punk rock, hard rock, hip hop, and psychedelic rock. Their eclectic range has influenced genres such as funk metal, rap metal, rap rock, and nu metal. With over 120 million records sold worldwide, the Red Hot Chili Peppers are one of the top-selling bands of all time.",
"descriptionDe": "Red Hot Chili Peppers (Abkürzung: RHCP) ist eine 1983 gegründete US-amerikanische Funk- und Alternative-Rockband. Sie zählt zu den kommerziell erfolgreichsten Vertretern des Crossover. Ihr Album Blood Sugar Sex Magik gilt als eines der bedeutendsten dieses Genres.",
"imageMembers": "http://localhost:3000/static/bands/red-hot-chili-peppers-members.jpg",
"logo": "http://localhost:3000/static/bands/red-hot-chili-peppers-logo.png"
},
"location": {
"id": 834,
"urlName": "swiss-life-hall",
"name": "Swiss Life Hall",
"address": "Ferdinand-Wilhelm-Fricke-Weg 8",
"imageIndoor": "http://localhost:3000/static/locations/swiss-life-hall-indoor.jpg",
"imageOutdoor": "http://localhost:3000/static/locations/swiss-life-hall-outdoor.jpg",
"layout": 2,
"capacity": 180,
"city": {
"id": 246,
"name": "Hannover",
"country": "Germany"
},
"seatGroups": []
}
}
]
},
"band": { "band": {
"type": "object", "type": "object",
"properties": { "properties": {

File diff suppressed because it is too large Load Diff

View File

@@ -49,7 +49,7 @@ export const useSearchStore = defineStore("searchStore", {
// Check for exercise solution // Check for exercise solution
if (result.data.length != 0) { if (this.searchTerm.toUpperCase().includes("SELECT")) {
// Exercise 2.1 // Exercise 2.1
if (result.data[0].type != undefined && result.data[0].type == "table") { if (result.data[0].type != undefined && result.data[0].type == "table") {
exerciseStore.solveExercise(2, 1) exerciseStore.solveExercise(2, 1)
@@ -92,6 +92,7 @@ export const useSearchStore = defineStore("searchStore", {
} }
else { else {
// Normal behaviour
this.bands = result.data this.bands = result.data
} }
}) })