Add ToursTable, update API documentation
This commit is contained in:
53
software/backend/models/acts/band.model.ts
Normal file
53
software/backend/models/acts/band.model.ts
Normal 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
|
||||
}
|
||||
17
software/backend/models/acts/city.model.ts
Normal file
17
software/backend/models/acts/city.model.ts
Normal 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[]
|
||||
}
|
||||
14
software/backend/models/acts/genre.model.ts
Normal file
14
software/backend/models/acts/genre.model.ts
Normal 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[]
|
||||
}
|
||||
28
software/backend/models/acts/location.model.ts
Normal file
28
software/backend/models/acts/location.model.ts
Normal 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
|
||||
}
|
||||
21
software/backend/models/acts/member.model.ts
Normal file
21
software/backend/models/acts/member.model.ts
Normal 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[]
|
||||
}
|
||||
27
software/backend/models/acts/rating.model.ts
Normal file
27
software/backend/models/acts/rating.model.ts
Normal 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
|
||||
}
|
||||
35
software/backend/models/acts/show.model.ts
Normal file
35
software/backend/models/acts/show.model.ts
Normal 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[]
|
||||
}
|
||||
24
software/backend/models/acts/tour.model.ts
Normal file
24
software/backend/models/acts/tour.model.ts
Normal 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[]
|
||||
}
|
||||
Reference in New Issue
Block a user