Add ToursTable, update API documentation

This commit is contained in:
2024-09-26 14:40:41 +02:00
parent da98fc73c0
commit 169fcdf03c
46 changed files with 776 additions and 829 deletions

View File

@@ -0,0 +1,53 @@
import { BelongsTo, Column, DataType, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
import { Member } from "./member.model";
import { Genre } from "./genre.model";
import { Rating } from "./rating.model";
import { Tour } from "./tour.model";
@Table({ timestamps: false })
export class Band extends Model {
@Column
name: String
@Column
foundingYear: Number
@Column
descriptionEn: String
@Column
descriptionDe: String
@Column({
type: DataType.STRING,
get(): Array<string> {
return this.getDataValue('images').split(';')
},
set(value: Array<string>) {
this.setDataValue('images', value.join(';'))
}
})
images: Array<String>
@Column
logo: String
@ForeignKey(() => Genre)
@Column
genreId: Number
// Relations
@HasMany(() => Member)
members: Member[]
@HasMany(() => Rating)
ratings: Rating[]
@HasMany(() => Tour)
tours: Tour[]
@BelongsTo(() => Genre)
genre: Genre
}

View File

@@ -0,0 +1,17 @@
import { Column, HasMany, Model, Table } from "sequelize-typescript";
import { Location } from "./location.model";
@Table({ timestamps: false })
export class City extends Model {
@Column
name: String
@Column
country: String
// Relations
@HasMany(() => Location)
locations: Location[]
}

View File

@@ -0,0 +1,14 @@
import { Column, HasMany, Model, Table } from "sequelize-typescript";
import { Band } from "./band.model";
@Table({ timestamps: false })
export class Genre extends Model {
@Column
name: String
// Relations
@HasMany(() => Band)
bands: Band[]
}

View File

@@ -0,0 +1,28 @@
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
import { Show } from "./show.model";
import { City } from "./city.model";
@Table({ timestamps: false })
export class Location extends Model {
@Column
name: String
@Column
address: String
@ForeignKey(() => City)
@Column
cityId: Number
@Column
image: String
// Relations
@HasMany(() => Show)
shows: Show[]
@BelongsTo(() => City)
city: City
}

View File

@@ -0,0 +1,21 @@
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
import { Band } from "./band.model";
@Table({ timestamps: false })
export class Member extends Model {
@Column
name: String
@ForeignKey(() => Band)
@Column
bandId: Number
@Column
image: String
// Relations
@BelongsTo(() => Band)
bands: Band[]
}

View File

@@ -0,0 +1,27 @@
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
import { Account } from "../user/account.model";
import { Band } from "./band.model";
@Table({ timestamps: false })
export class Rating extends Model {
@ForeignKey(() => Account)
@Column
accountId: Number
@Column
rating: Number
@ForeignKey(() => Band)
@Column
bandId: Number
// Relations
@BelongsTo(() => Account)
account: Account
@BelongsTo(() => Band)
band: Band
}

View File

@@ -0,0 +1,35 @@
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
import { Location } from "./location.model";
import { Tour } from "./tour.model";
import { OrderItem } from "../ordering/orderItem.model";
@Table({ timestamps: false })
export class Show extends Model {
@Column
date: String
@Column
price: Number
@Column
inStock: Number
@ForeignKey(() => Location)
@Column
locationId: Number
@ForeignKey(() => Tour)
tourId: Number
// Relations
@BelongsTo(() => Tour)
tour: Tour
@BelongsTo(() => Location)
location: Location
@HasMany(() => OrderItem)
orderItems: OrderItem[]
}

View File

@@ -0,0 +1,24 @@
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
import { Band } from "./band.model";
import { Show } from "./show.model";
@Table({ timestamps: false })
export class Tour extends Model {
@Column
name: String
@ForeignKey(() => Band)
bandId: Number
@Column
offered: Boolean
// Relations
@BelongsTo(() => Band)
band: Band
@HasMany(() => Show)
shows: Show[]
}