Atomize model classes

This commit is contained in:
2024-10-11 17:42:21 +02:00
parent cfb8fb9d7d
commit 0ec11aacf7
59 changed files with 432 additions and 356 deletions

View File

@@ -0,0 +1,12 @@
import { BandModel } from "./bandModel";
import { EventApiModel } from "./eventApiModel";
import { GenreModel } from "./genreModel"
import { MemberModel } from "./memberModel"
import { RatingModel } from "./ratingModel"
export class BandApiModel extends BandModel {
ratings: Array<RatingModel> = []
members: Array<MemberModel> = []
genres: Array<GenreModel> = []
events: Array<EventApiModel> = []
}

View File

@@ -1,22 +1,10 @@
import { EventModel } from "./eventModel"
import { RatingModel } from "./ratingModel"
export class BandModel {
id: number
name: string
foundingYear: number
descriptionEn: string
descriptionDe: string
images: Array<string>
imageMembers: string
logo: string
ratings: Array<RatingModel> = []
members: Array<{
name: string,
image: string
}>
genres: Array<{
name: string
}> = []
events: Array<EventModel>
id: number = -1
name: string = ""
foundingYear: number = 1900
descriptionEn: string = ""
descriptionDe: string = ""
images: Array<string> = []
imageMembers: string = ""
logo: string = ""
}

View File

@@ -0,0 +1,8 @@
import { LocationApiModel } from "../locations/locationApiModel"
import { ConcertModel } from "./concertModel"
import { EventApiModel } from "./eventApiModel"
export class ConcertApiModel extends ConcertModel {
location: LocationApiModel = new LocationApiModel()
event: EventApiModel = new EventApiModel()
}

View File

@@ -1,24 +1,6 @@
import { LocationModel } from "./../locations/locationModel"
import { BandModel } from "./bandModel"
import { EventModel } from "./eventModel"
export class ConcertModel {
id: number = 0
id: number = -1
inStock: number = 0
date: string = ""
price: number = 0
location: LocationModel = new LocationModel()
event: {
id: number
name: string
offered: boolean
image: string
band: BandModel
} = {
id: 0,
name: "",
offered: true,
image: "",
band: new BandModel()
}
}

View File

@@ -0,0 +1,8 @@
import { EventModel } from "./eventModel";
import { BandModel } from "./bandModel"
import { ConcertApiModel } from "./concertApiModel";
export class EventApiModel extends EventModel {
concerts: Array<ConcertApiModel> = []
band: BandModel = new BandModel()
}

View File

@@ -1,11 +1,6 @@
import { BandModel } from "./bandModel"
import { ConcertModel } from "./concertModel"
export class EventModel {
id: number
name: string
offered: boolean
image: string
band: BandModel = new BandModel()
concerts: Array<ConcertModel> = [ new ConcertModel() ]
id: number = -1
name: string = ""
offered: boolean = true
image: string = ""
}

View File

@@ -0,0 +1,6 @@
import { GenreModel } from "./genreModel";
import { BandModel } from "./bandModel"
export class GenreApiModel extends GenreModel {
bands: Array<BandModel>
}

View File

@@ -1,14 +1,4 @@
import { RatingModel } from "./ratingModel"
export class GenreModel {
id: number
name: string
bands: Array<
{
name: string
images: Array<string>
logo: string
ratings: Array<RatingModel>
}
>
id: number = -1
name: string = ""
}

View File

@@ -0,0 +1,4 @@
export class MemberModel {
name: string = ""
image: string = ""
}

View File

@@ -1,7 +1,4 @@
import { BandModel } from "./bandModel"
export class RatingModel {
id: number
rating: number
band: BandModel
id: number = -1
rating: number = 1
}

View File

@@ -1,14 +0,0 @@
import { BandModel } from "./bandModel"
import { ConcertModel } from "./concertModel"
/**
* @deprecated Use EventModel!
*/
export class TourModel {
id: number
name: string
offered: boolean
band: BandModel
image: string
concerts: Array<ConcertModel>
}

View File

@@ -0,0 +1,6 @@
import { ExerciseModel } from "./exerciseModel";
import { ExerciseGroupModel } from "./exerciseGroupModel";
export class ExerciseGroupApiModel extends ExerciseGroupModel {
exercises: Array<ExerciseModel>
}

View File

@@ -1,8 +1,6 @@
import { ExerciseModel } from "./exerciseModel"
export class ExerciseGroupModel {
id = -1
nameDe: string = ""
nameEn: string = ""
groupNr: number = 0
exercises: Array<ExerciseModel>
}

View File

@@ -1,4 +1,5 @@
export class ExerciseModel {
id = -1
nameDe: string = ""
nameEn: string = ""
exerciseNr: number = 0

View File

@@ -0,0 +1,12 @@
import { LocationApiModel } from "./locationApiModel"
/**
* Replica of the API endpoint /cities
*/
export class CityApiModel {
id: number = -1
name: string = ""
country: string = ""
image: string = ""
locations: Array<LocationApiModel>
}

View File

@@ -1,24 +1,6 @@
/**
* Replica of the API endpoint /cities
*/
export class CityModel {
id: number = -1
name: string = ""
country: string = ""
image: string = ""
locations: Array<{
id: number
name: string
address: string
imageIndoor: string
imageOutdoor: string
nrOfConcerts: number
}> = [{
id: -1,
name: "",
address: "",
imageIndoor: "",
imageOutdoor: "",
nrOfConcerts: 0
}]
}

View File

@@ -0,0 +1,13 @@
import { ConcertApiModel } from "../acts/concertApiModel"
import { CityModel } from "./cityModel"
import { LocationModel } from "./locationModel"
import { SeatGroupModel } from "./seatGroupModel"
/**
* Replica of the API endpoint /locations
*/
export class LocationApiModel extends LocationModel {
city: CityModel = new CityModel()
concerts: Array<ConcertApiModel> = []
seatGroups: Array<SeatGroupModel> = []
}

View File

@@ -1,32 +1,8 @@
import { SeatGroupModel } from "./seatGroupModel"
/**
* Replica of the API endpoint /locations
*/
export class LocationModel {
id: number
name: string
address: string
imageIndoor: string
imageOutdoor: string
seatSchema: string
layout: number
city: {
name: string
country: string
} = { name: "", country: "" }
concerts: Array<{
id: number
date: string
price: number
inStock: number
location: string
event: {
name: string
offered: boolean
image: string
bandName: string
}
}>
seatGroups: Array<SeatGroupModel>
id: number = -1
name: string = ""
address: string = ""
imageIndoor: string = ""
imageOutdoor: string = ""
layout: number = 1
}

View File

@@ -1,9 +1,9 @@
import { SeatRowModel } from "./seatRowModel"
export class SeatGroupModel {
name: string
surcharge: number
standingArea: Boolean
capacity: number
name: string = ""
surcharge: number = 0
standingArea: Boolean = false
capacity: number = 0
seatRows: Array<SeatRowModel>
}

View File

@@ -1,5 +1,5 @@
export class SeatModel {
id: number
seatNr: string
id: number = -1
seatNr: string = ""
state: number = 0
}

View File

@@ -1,6 +1,6 @@
import { SeatModel } from "./seatModel"
export class SeatRowModel {
row: number
row: number = 0
seats: Array<SeatModel>
}

View File

@@ -1,13 +1,20 @@
import { BandApiModel } from "../acts/bandApiModel"
import { BandModel } from "../acts/bandModel"
import { ConcertModel } from "../acts/concertModel"
import { EventModel } from "../acts/eventModel"
import { SeatModel } from "../locations/seatModel"
export class BasketItemModel {
concert: ConcertModel = new ConcertModel()
concert: ConcertModel
event: EventModel
band: BandModel = new BandModel()
seats: Array<SeatModel> = []
price: number
constructor(concert: ConcertModel, seat: SeatModel, price: number) {
constructor(concert: ConcertModel, event: EventModel, band: BandModel, seat: SeatModel, price: number) {
this.concert = concert
this.event = event
this.band = band
this.seats = [ seat ]
this.price = price
}

View File

@@ -0,0 +1,12 @@
import { AccountModel } from "../user/accountModel"
import { AddressModel } from "../user/addressModel"
import { PaymentModel } from "../user/paymentModel"
import { OrderModel } from "./orderModel"
import { TicketApiModel } from "./ticketApiModel"
export class OrderApiModel extends OrderModel {
tickets: Array<TicketApiModel>
account: AccountModel
payment: PaymentModel
address: AddressModel
}

View File

@@ -1,13 +1,5 @@
import { AddressModel } from "../user/addressModel"
import { PaymentModel } from "../user/paymentModel"
import { TicketModel } from "./ticketModel"
export class OrderModel {
id: number
accountId: number
shippingProgress: number
tickets: Array<TicketModel>
orderedAt: string
payment: PaymentModel
address: AddressModel
}

View File

@@ -0,0 +1,8 @@
import { ConcertApiModel } from "../acts/concertApiModel";
import { SeatModel } from "../locations/seatModel";
import { TicketModel } from "./ticketModel";
export class TicketApiModel extends TicketModel {
concert: ConcertApiModel
seat: SeatModel
}

View File

@@ -1,20 +1,5 @@
import { ConcertModel } from "../acts/concertModel"
import { SeatModel } from "../locations/seatModel"
export class TicketModel {
id: number
orderId: number = -1
orderPrice: number = 0
concert: ConcertModel
seat: {
seatNr: number,
seatRow: {
row: number,
seatGroup: {
name: string,
surcharge: number,
standingArea: boolean
}
}
}
}

View File

@@ -0,0 +1,10 @@
import { AccountModel } from "./accountModel"
import { AccountRole } from "./accountRole"
import { AddressModel } from "./addressModel"
import { PaymentModel } from "./paymentModel"
export class AccountApiModel extends AccountModel {
addresses: Array<AddressModel>
payments: Array<PaymentModel>
accountRole: AccountRole
}

View File

@@ -1,7 +1,3 @@
import { AccountRole } from "./accountRole"
import { AddressModel } from "./addressModel"
import { PaymentModel } from "./paymentModel"
export class AccountModel {
id: number
username: string = ""
@@ -9,7 +5,4 @@ export class AccountModel {
email: string = ""
firstName: string = ""
lastName: string = ""
addresses: Array<AddressModel> = [ new AddressModel() ]
payments: Array<PaymentModel> = [ new PaymentModel() ]
accountRole: AccountRole = new AccountRole()
}