Add ToursTable, update API documentation
This commit is contained in:
78
README.md
78
README.md
@@ -74,7 +74,7 @@ The application host it's data in a SQLite database. The access is managed by an
|
|||||||
#### Listing existing
|
#### Listing existing
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/products/</b></code> <code> (Get all products)</code>
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/bands</b></code> <code> (Get all bands)</code>
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
##### Parameters
|
##### Parameters
|
||||||
@@ -83,11 +83,13 @@ The application host it's data in a SQLite database. The access is managed by an
|
|||||||
##### Responses
|
##### Responses
|
||||||
> | http code | content-type | response |
|
> | http code | content-type | response |
|
||||||
> | :---: | --- | --- |
|
> | :---: | --- | --- |
|
||||||
> | `200` | `application/json` | `Array<ProductModel>` + `Category`, `Brand` |
|
> | `200` | `application/json` | `Array<Band>` |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/products/:id</b></code> <code> (Get a product by it's id)</code>
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/bands/:id</b></code> <code> (Get all information about one band)</code>
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
##### Parameters
|
##### Parameters
|
||||||
@@ -98,9 +100,72 @@ The application host it's data in a SQLite database. The access is managed by an
|
|||||||
##### Responses
|
##### Responses
|
||||||
> | http code | content-type | response |
|
> | http code | content-type | response |
|
||||||
> | :---: | --- | --- |
|
> | :---: | --- | --- |
|
||||||
> | `200` | `application/json` | `ProductModel` + `Category`, `Brand` |
|
> | `200` | `application/json` | `Band` + `Array<Rating>` + `Array<Member>` |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<details open>
|
||||||
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/shows/:id</b></code> <code> (Get all information about one show)</code>
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
##### Parameters
|
||||||
|
> | name | type | data type | description |
|
||||||
|
> | :---: | --- | --- | --- |
|
||||||
|
> | `id` | required | string | ID of product in the database |
|
||||||
|
|
||||||
|
##### Responses
|
||||||
|
> | http code | content-type | response |
|
||||||
|
> | :---: | --- | --- |
|
||||||
|
> | `200` | `application/json` | `Show` + `Tour` + `Location` + `City` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<details open>
|
||||||
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/tours</b></code> <code> (Get all tours)</code>
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
##### Parameters
|
||||||
|
> None
|
||||||
|
|
||||||
|
##### Responses
|
||||||
|
> | http code | content-type | response |
|
||||||
|
> | :---: | --- | --- |
|
||||||
|
> | `200` | `application/json` | `Array<Tours>` + `Band` + `Show` + `Location` + `City` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
<details open>
|
||||||
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/genres</b></code> <code> (Get all genres)</code>
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
##### Parameters
|
||||||
|
> None
|
||||||
|
|
||||||
|
##### Responses
|
||||||
|
> | http code | content-type | response |
|
||||||
|
> | :---: | --- | --- |
|
||||||
|
> | `200` | `application/json` | `Array<Genre>` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<details open>
|
||||||
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/locations</b></code> <code> (Get all locations)</code>
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
##### Parameters
|
||||||
|
> None
|
||||||
|
|
||||||
|
##### Responses
|
||||||
|
> | http code | content-type | response |
|
||||||
|
> | :---: | --- | --- |
|
||||||
|
> | `200` | `application/json` | `Array<Location>` + `City` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/orders/:id</b></code> <code> (Get all orders of an user)</code>
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/orders/:id</b></code> <code> (Get all orders of an user)</code>
|
||||||
</summary>
|
</summary>
|
||||||
@@ -116,6 +181,8 @@ The application host it's data in a SQLite database. The access is managed by an
|
|||||||
> | `200` | `application/json` | `ProductModel` + `Order`, `OrderItem`, `Product` |
|
> | `200` | `application/json` | `ProductModel` + `Order`, `OrderItem`, `Product` |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/categories/</b></code> <code> (Get all Categories)</code>
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/categories/</b></code> <code> (Get all Categories)</code>
|
||||||
</summary>
|
</summary>
|
||||||
@@ -130,6 +197,7 @@ The application host it's data in a SQLite database. The access is managed by an
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/brands</b></code> <code> (Get all Brands)</code>
|
<summary><code><span style="color:#70AFFD"><b>GET</b></span></code> <code><b>/brands</b></code> <code> (Get all Brands)</code>
|
||||||
</summary>
|
</summary>
|
||||||
@@ -143,8 +211,10 @@ The application host it's data in a SQLite database. The access is managed by an
|
|||||||
> | `200` | `application/json` | `Array<Brand>` |
|
> | `200` | `application/json` | `Array<Brand>` |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
#### Creating new
|
#### Creating new
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|||||||
1033
misc/database.drawio
1033
misc/database.drawio
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 261 KiB |
9
software/backend/data/cities.json
Normal file
9
software/backend/data/cities.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "Hannover",
|
||||||
|
"country": "Germany"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
{
|
{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"name": "Swiss Life Hall",
|
"name": "Swiss Life Hall",
|
||||||
"address": "Ferdinand-Wilhlem-Fricke-Weg 8, 30169 Hannover",
|
"address": "Ferdinand-Wilhlem-Fricke-Weg 8",
|
||||||
|
"cityId": 0,
|
||||||
"image": "swiss-life-hall.jpg"
|
"image": "swiss-life-hall.jpg"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
{
|
{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"orderId": 0,
|
"orderId": 0,
|
||||||
"productId": 0,
|
"showId": 0,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
"orderPrice": 184
|
"orderPrice": 184
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"id": 0,
|
|
||||||
"name": "Unlimited Love Tour",
|
|
||||||
"bandId": 0,
|
|
||||||
"date": "2024-12-03",
|
|
||||||
"price": 92,
|
|
||||||
"inStock": 230,
|
|
||||||
"offered": true,
|
|
||||||
"locationId": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
20
software/backend/data/tours.json
Normal file
20
software/backend/data/tours.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "Unlimited Love Tour",
|
||||||
|
"bandId": 0,
|
||||||
|
"offered": true,
|
||||||
|
"shows": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"date": "2024-12-03",
|
||||||
|
"price": 92,
|
||||||
|
"inStock": 230,
|
||||||
|
"locationId": 0,
|
||||||
|
"tourId": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,19 +1,21 @@
|
|||||||
import { Sequelize } from "sequelize-typescript"
|
import { Sequelize } from "sequelize-typescript"
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
import { Order } from "./models/order.model"
|
import { Order } from "./models/ordering/order.model"
|
||||||
import { OrderItem } from "./models/orderItem.model"
|
import { OrderItem } from "./models/ordering/orderItem.model"
|
||||||
import { Account } from "./models/account.model"
|
import { Account } from "./models/user/account.model"
|
||||||
import { prepopulateDatabase } from "./scripts/databaseHelper"
|
import { prepopulateDatabase } from "./scripts/databaseHelper"
|
||||||
import { Address } from "./models/address.model"
|
import { Address } from "./models/user/address.model"
|
||||||
import { Payment } from "./models/payment.model"
|
import { Payment } from "./models/user/payment.model"
|
||||||
import { AccountRole } from "./models/accountRole.model"
|
import { AccountRole } from "./models/user/accountRole.model"
|
||||||
import { Genre } from "./models/genre.model"
|
import { Genre } from "./models/acts/genre.model"
|
||||||
import { Location } from "./models/location.model"
|
import { Location } from "./models/acts/location.model"
|
||||||
import { Band } from "./models/band.model"
|
import { Band } from "./models/acts/band.model"
|
||||||
import { Show } from "./models/show.model"
|
import { Show } from "./models/acts/show.model"
|
||||||
import { Member } from "./models/member.model"
|
import { Member } from "./models/acts/member.model"
|
||||||
import { Rating } from "./models/rating.model"
|
import { Rating } from "./models/acts/rating.model"
|
||||||
|
import { Tour } from "./models/acts/tour.model"
|
||||||
|
import { City } from "./models/acts/city.model"
|
||||||
|
|
||||||
const dbName = "database"
|
const dbName = "database"
|
||||||
const dbUser = "root"
|
const dbUser = "root"
|
||||||
@@ -26,12 +28,16 @@ export const sequelize = new Sequelize({
|
|||||||
username: dbUser,
|
username: dbUser,
|
||||||
password: dbPassword,
|
password: dbPassword,
|
||||||
storage: "database.sqlite",
|
storage: "database.sqlite",
|
||||||
models: [ Genre, Location, AccountRole, Account, Payment, Address, Order, Band, Show, Member, Rating, OrderItem ]
|
models: [
|
||||||
|
AccountRole, Account, Payment, Address,
|
||||||
|
City, Location, Genre, Band, Rating, Member, Tour, Show,
|
||||||
|
Order, OrderItem
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export function startDatabase() {
|
export function startDatabase() {
|
||||||
// Create database and tables
|
// Create database and tables
|
||||||
sequelize.sync({ force: false })
|
sequelize.sync({ force: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("Database & tables created!")
|
console.log("Database & tables created!")
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 183 KiB |
@@ -2,6 +2,7 @@ import { BelongsTo, Column, DataType, ForeignKey, HasMany, Model, Table } from "
|
|||||||
import { Member } from "./member.model";
|
import { Member } from "./member.model";
|
||||||
import { Genre } from "./genre.model";
|
import { Genre } from "./genre.model";
|
||||||
import { Rating } from "./rating.model";
|
import { Rating } from "./rating.model";
|
||||||
|
import { Tour } from "./tour.model";
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
@Table({ timestamps: false })
|
||||||
export class Band extends Model {
|
export class Band extends Model {
|
||||||
@@ -44,6 +45,9 @@ export class Band extends Model {
|
|||||||
@HasMany(() => Rating)
|
@HasMany(() => Rating)
|
||||||
ratings: Rating[]
|
ratings: Rating[]
|
||||||
|
|
||||||
|
@HasMany(() => Tour)
|
||||||
|
tours: Tour[]
|
||||||
|
|
||||||
@BelongsTo(() => Genre)
|
@BelongsTo(() => Genre)
|
||||||
genre: 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[]
|
||||||
|
}
|
||||||
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
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
|
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
|
||||||
import { Account } from "./account.model";
|
import { Account } from "../user/account.model";
|
||||||
import { Band } from "./band.model";
|
import { Band } from "./band.model";
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
@Table({ timestamps: false })
|
||||||
@@ -1,15 +1,10 @@
|
|||||||
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
|
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
|
||||||
import { Band } from "./band.model";
|
|
||||||
import { Location } from "./location.model";
|
import { Location } from "./location.model";
|
||||||
|
import { Tour } from "./tour.model";
|
||||||
|
import { OrderItem } from "../ordering/orderItem.model";
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
@Table({ timestamps: false })
|
||||||
export class Show extends Model {
|
export class Show extends Model {
|
||||||
@Column
|
|
||||||
name: String
|
|
||||||
|
|
||||||
@ForeignKey(() => Band)
|
|
||||||
bandId: Number
|
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
date: String
|
date: String
|
||||||
|
|
||||||
@@ -19,19 +14,22 @@ export class Show extends Model {
|
|||||||
@Column
|
@Column
|
||||||
inStock: Number
|
inStock: Number
|
||||||
|
|
||||||
@Column
|
|
||||||
offered: Boolean
|
|
||||||
|
|
||||||
@ForeignKey(() => Location)
|
@ForeignKey(() => Location)
|
||||||
@Column
|
@Column
|
||||||
locationId: Number
|
locationId: Number
|
||||||
|
|
||||||
|
@ForeignKey(() => Tour)
|
||||||
|
tourId: Number
|
||||||
|
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
|
|
||||||
@BelongsTo(() => Band)
|
@BelongsTo(() => Tour)
|
||||||
band: Band
|
tour: Tour
|
||||||
|
|
||||||
@BelongsTo(() => Location)
|
@BelongsTo(() => Location)
|
||||||
location: 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[]
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import { Column, Model, Table } from "sequelize-typescript";
|
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
|
||||||
export class Location extends Model {
|
|
||||||
@Column
|
|
||||||
name: String
|
|
||||||
|
|
||||||
@Column
|
|
||||||
address: String
|
|
||||||
|
|
||||||
@Column
|
|
||||||
image: String
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Table, Column, Model, BelongsTo, ForeignKey, HasMany, BelongsToMany, Default } from 'sequelize-typescript';
|
import { Table, Column, Model, BelongsTo, ForeignKey, HasMany, BelongsToMany, Default } from 'sequelize-typescript';
|
||||||
import { Account } from './account.model';
|
import { Account } from '../user/account.model';
|
||||||
import { OrderItem } from './orderItem.model';
|
import { OrderItem } from './orderItem.model';
|
||||||
import { Address } from './address.model';
|
import { Address } from '../user/address.model';
|
||||||
import { Payment } from './payment.model';
|
import { Payment } from '../user/payment.model';
|
||||||
|
|
||||||
@Table({
|
@Table({
|
||||||
updatedAt: false,
|
updatedAt: false,
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Model, BelongsTo, Column, ForeignKey, HasMany, HasOne, Table } from "sequelize-typescript";
|
import { Model, BelongsTo, Column, ForeignKey, HasMany, HasOne, Table } from "sequelize-typescript";
|
||||||
import { Show } from "./show.model";
|
import { Show } from "../acts/show.model";
|
||||||
import { Order } from "./order.model";
|
import { Order } from "./order.model";
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
@Table({ timestamps: false })
|
||||||
@@ -16,7 +16,7 @@ export class OrderItem extends Model {
|
|||||||
|
|
||||||
@Column
|
@Column
|
||||||
@ForeignKey(() => Show)
|
@ForeignKey(() => Show)
|
||||||
productId: number
|
showId: number
|
||||||
|
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Table, Column, Model, HasMany, Unique, BelongsTo, ForeignKey } from 'sequelize-typescript';
|
import { Table, Column, Model, HasMany, Unique, BelongsTo, ForeignKey } from 'sequelize-typescript';
|
||||||
import { Order } from './order.model';
|
import { Order } from '../ordering/order.model';
|
||||||
import { Address } from './address.model';
|
import { Address } from './address.model';
|
||||||
import { Payment } from './payment.model';
|
import { Payment } from './payment.model';
|
||||||
import { AccountRole } from './accountRole.model';
|
import { AccountRole } from './accountRole.model';
|
||||||
import { Rating } from './rating.model';
|
import { Rating } from '../acts/rating.model';
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
@Table({ timestamps: false })
|
||||||
export class Account extends Model {
|
export class Account extends Model {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
|
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
|
||||||
import { Account } from "./account.model";
|
import { Account } from "./account.model";
|
||||||
import { Order } from "./order.model";
|
import { Order } from "../ordering/order.model";
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
@Table({ timestamps: false })
|
||||||
export class Address extends Model {
|
export class Address extends Model {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
|
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
|
||||||
import { Account } from "./account.model";
|
import { Account } from "./account.model";
|
||||||
import { Order } from "./order.model";
|
import { Order } from "../ordering/order.model";
|
||||||
|
|
||||||
@Table({ timestamps: false })
|
@Table({ timestamps: false })
|
||||||
export class Payment extends Model {
|
export class Payment extends Model {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { Account } from "../models/account.model";
|
import { Account } from "../models/user/account.model";
|
||||||
import { validateString } from "../scripts/validateHelper";
|
import { validateString } from "../scripts/validateHelper";
|
||||||
import { Address } from "../models/address.model";
|
import { Address } from "../models/user/address.model";
|
||||||
import { Payment } from "../models/payment.model";
|
import { Payment } from "../models/user/payment.model";
|
||||||
import { AccountRole } from "../models/accountRole.model";
|
import { AccountRole } from "../models/user/accountRole.model";
|
||||||
|
|
||||||
export const account = Router()
|
export const account = Router()
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,42 @@
|
|||||||
import { Member } from "../models/member.model";
|
import { Member } from "../models/acts/member.model";
|
||||||
import { Band } from "../models/band.model";
|
import { Band } from "../models/acts/band.model";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { Rating } from "../models/rating.model";
|
import { Rating } from "../models/acts/rating.model";
|
||||||
import { Genre } from "../models/genre.model";
|
import { Genre } from "../models/acts/genre.model";
|
||||||
|
|
||||||
export const band = Router()
|
export const band = Router()
|
||||||
|
|
||||||
|
// Get all bands
|
||||||
band.get("/", (req: Request, res: Response) => {
|
band.get("/", (req: Request, res: Response) => {
|
||||||
Band.findAll({
|
Band.findAll()
|
||||||
include: [ Member, Rating, Genre ]
|
|
||||||
})
|
|
||||||
.then(bands => {
|
.then(bands => {
|
||||||
res.status(200).json(bands)
|
res.status(200).json(bands)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Get all information about one band
|
||||||
|
band.get("/:id", (req: Request, res: Response) => {
|
||||||
|
Band.findByPk(req.params.id, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: Member,
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "bandId" ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
model: Rating,
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "bandId" ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Genre
|
||||||
|
],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "genreId" ]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(band => {
|
||||||
|
res.status(200).json(band)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Genre } from "../models/genre.model";
|
import { Genre } from "../models/acts/genre.model";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
|
|
||||||
export const genre = Router()
|
export const genre = Router()
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
import { Location } from "../models/location.model";
|
import { City } from "../models/acts/city.model";
|
||||||
|
import { Location } from "../models/acts/location.model";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
|
|
||||||
export const location = Router()
|
export const location = Router()
|
||||||
|
|
||||||
location.get("/", (req: Request, res: Response) => {
|
location.get("/", (req: Request, res: Response) => {
|
||||||
Location.findAll()
|
Location.findAll({
|
||||||
|
include: [ City ],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "cityId" ]
|
||||||
|
}
|
||||||
|
})
|
||||||
.then(locations => {
|
.then(locations => {
|
||||||
res.status(200).json(locations)
|
res.status(200).json(locations)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { Order } from "../models/order.model";
|
import { Order } from "../models/ordering/order.model";
|
||||||
import { Show } from "../models/show.model";
|
import { Show } from "../models/acts/show.model";
|
||||||
import { OrderItem } from "../models/orderItem.model";
|
import { OrderItem } from "../models/ordering/orderItem.model";
|
||||||
import { Payment } from "../models/payment.model";
|
import { Payment } from "../models/user/payment.model";
|
||||||
import { Address } from "../models/address.model";
|
import { Address } from "../models/user/address.model";
|
||||||
import { Band } from "../models/band.model";
|
import { Band } from "../models/acts/band.model";
|
||||||
import { Location } from "../models/location.model";
|
import { Location } from "../models/acts/location.model";
|
||||||
|
|
||||||
export const order = Router()
|
export const order = Router()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,27 @@
|
|||||||
import { Show } from "../models/show.model";
|
import { Location } from "../models/acts/location.model";
|
||||||
|
import { Show } from "../models/acts/show.model";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
|
import { Tour } from "../models/acts/tour.model";
|
||||||
|
import { City } from "../models/acts/city.model";
|
||||||
|
|
||||||
export const show = Router()
|
export const show = Router()
|
||||||
|
|
||||||
show.get("/", (req: Request, res: Response) => {
|
show.get("/:id", (req: Request, res: Response) => {
|
||||||
Show.findAll()
|
Show.findByPk(req.params.id, {
|
||||||
|
include: [
|
||||||
|
Tour,
|
||||||
|
{
|
||||||
|
model: Location,
|
||||||
|
include: [ City ],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "cityId" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "locationId", "tourId" ]
|
||||||
|
}
|
||||||
|
})
|
||||||
.then(shows => {
|
.then(shows => {
|
||||||
res.status(200).json(shows)
|
res.status(200).json(shows)
|
||||||
})
|
})
|
||||||
|
|||||||
44
software/backend/routes/tour.routes.ts
Normal file
44
software/backend/routes/tour.routes.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { Show } from "../models/acts/show.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/acts/location.model";
|
||||||
|
import { Genre } from "../models/acts/genre.model";
|
||||||
|
import { City } from "../models/acts/city.model";
|
||||||
|
|
||||||
|
export const tour = Router()
|
||||||
|
|
||||||
|
tour.get("/", (req: Request, res: Response) => {
|
||||||
|
Tour.findAll({
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: Band,
|
||||||
|
include: [ Genre ],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "genreId" ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
model: Show,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: Location,
|
||||||
|
include: [ City ],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "cityId" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "locationId", "tourId" ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
attributes: {
|
||||||
|
exclude: [ "bandId" ]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(tours => {
|
||||||
|
res.status(200).json(tours)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
import { Order } from '../models/order.model'
|
import { Order } from '../models/ordering/order.model'
|
||||||
import { OrderItem } from '../models/orderItem.model'
|
import { OrderItem } from '../models/ordering/orderItem.model'
|
||||||
import { Account } from '../models/account.model'
|
import { Account } from '../models/user/account.model'
|
||||||
import { Address } from '../models/address.model'
|
import { Address } from '../models/user/address.model'
|
||||||
import { Payment } from '../models/payment.model'
|
import { Payment } from '../models/user/payment.model'
|
||||||
import { AccountRole } from '../models/accountRole.model'
|
import { AccountRole } from '../models/user/accountRole.model'
|
||||||
import { Rating } from '../models/rating.model'
|
import { Rating } from '../models/acts/rating.model'
|
||||||
import { Member } from '../models/member.model'
|
import { Member } from '../models/acts/member.model'
|
||||||
import { Genre } from '../models/genre.model'
|
import { Genre } from '../models/acts/genre.model'
|
||||||
import { Band } from '../models/band.model'
|
import { Band } from '../models/acts/band.model'
|
||||||
import { Location } from '../models/location.model'
|
import { Location } from '../models/acts/location.model'
|
||||||
import { Show } from '../models/show.model'
|
import { Show } from '../models/acts/show.model'
|
||||||
|
import { Tour } from '../models/acts/tour.model'
|
||||||
|
import { City } from '../models/acts/city.model'
|
||||||
|
|
||||||
import accounts from "./../data/accounts.json"
|
import accounts from "./../data/accounts.json"
|
||||||
import orders from "./../data/orders.json"
|
import orders from "./../data/orders.json"
|
||||||
@@ -18,7 +20,8 @@ import accountRoles from "./../data/accountRoles.json"
|
|||||||
import bands from "./../data/bands.json"
|
import bands from "./../data/bands.json"
|
||||||
import genres from "./../data/genres.json"
|
import genres from "./../data/genres.json"
|
||||||
import locations from "./../data/locations.json"
|
import locations from "./../data/locations.json"
|
||||||
import shows from "./../data/shows.json"
|
import tours from "./../data/tours.json"
|
||||||
|
import cities from "./../data/cities.json"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,6 +50,7 @@ export function deleteAllTables() {
|
|||||||
export async function prepopulateDatabase() {
|
export async function prepopulateDatabase() {
|
||||||
AccountRole.bulkCreate(accountRoles.data)
|
AccountRole.bulkCreate(accountRoles.data)
|
||||||
Genre.bulkCreate(genres.data)
|
Genre.bulkCreate(genres.data)
|
||||||
|
City.bulkCreate(cities.data)
|
||||||
Location.bulkCreate(locations.data)
|
Location.bulkCreate(locations.data)
|
||||||
|
|
||||||
// Account & Sub tables
|
// Account & Sub tables
|
||||||
@@ -68,7 +72,15 @@ export async function prepopulateDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Show.bulkCreate(shows.data)
|
for (let tour of tours.data) {
|
||||||
|
await Tour.create(tour)
|
||||||
|
.then(async dataset => {
|
||||||
|
for (let show of tour.shows) {
|
||||||
|
await Show.create(show)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Order.bulkCreate(orders.data)
|
Order.bulkCreate(orders.data)
|
||||||
OrderItem.bulkCreate(orderItems.data)
|
OrderItem.bulkCreate(orderItems.data)
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import { show } from './routes/show.routes'
|
|||||||
import { band } from './routes/band.routes'
|
import { band } from './routes/band.routes'
|
||||||
import { genre } from './routes/genre.routes'
|
import { genre } from './routes/genre.routes'
|
||||||
import { location } from './routes/location.routes'
|
import { location } from './routes/location.routes'
|
||||||
|
import { tour } from './routes/tour.routes'
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const port = 3000
|
const port = 3000
|
||||||
@@ -27,9 +28,9 @@ const path = require('path')
|
|||||||
app.use('/static', express.static(path.join(__dirname, 'images')))
|
app.use('/static', express.static(path.join(__dirname, 'images')))
|
||||||
|
|
||||||
// Add delay for more realistic response times
|
// Add delay for more realistic response times
|
||||||
app.use((req, res, next) => {
|
// app.use((req, res, next) => {
|
||||||
setTimeout(next, Math.floor((Math.random () * 4000) + 100))
|
// setTimeout(next, Math.floor((Math.random () * 4000) + 100))
|
||||||
})
|
// })
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
app.use("/api", api)
|
app.use("/api", api)
|
||||||
@@ -39,6 +40,7 @@ app.use("/genres", genre)
|
|||||||
app.use("/locations", location)
|
app.use("/locations", location)
|
||||||
app.use("/orders", order)
|
app.use("/orders", order)
|
||||||
app.use("/accounts", account)
|
app.use("/accounts", account)
|
||||||
|
app.use("/tours", tour)
|
||||||
|
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
|
|||||||
16
software/src/data/models/bandModel.ts
Normal file
16
software/src/data/models/bandModel.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { GenreModel } from "./genreModel"
|
||||||
|
import { MemberModel } from "./memberModel"
|
||||||
|
import { RatingModel } from "./ratingModel"
|
||||||
|
|
||||||
|
export class BandModel {
|
||||||
|
id: Number
|
||||||
|
name: string
|
||||||
|
foundingYear: Number
|
||||||
|
descriptionEn: String
|
||||||
|
descriptionDe: String
|
||||||
|
images: Array<String>
|
||||||
|
logo: String
|
||||||
|
genre: GenreModel
|
||||||
|
ratings: Array<RatingModel>
|
||||||
|
members: Array<MemberModel>
|
||||||
|
}
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
export class BrandModel {
|
|
||||||
id: number = 0
|
|
||||||
name: string = ""
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export class CategoryModel {
|
|
||||||
id: number = -1
|
|
||||||
name: string
|
|
||||||
icon: string
|
|
||||||
}
|
|
||||||
4
software/src/data/models/genreModel.ts
Normal file
4
software/src/data/models/genreModel.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export class GenreModel {
|
||||||
|
id: Number
|
||||||
|
name: String
|
||||||
|
}
|
||||||
7
software/src/data/models/locationModel.ts
Normal file
7
software/src/data/models/locationModel.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export class LocationModel {
|
||||||
|
id: Number
|
||||||
|
name: String
|
||||||
|
address: String
|
||||||
|
city: String
|
||||||
|
image: String
|
||||||
|
}
|
||||||
8
software/src/data/models/memberModel.ts
Normal file
8
software/src/data/models/memberModel.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { BandModel } from "./bandModel"
|
||||||
|
|
||||||
|
export class MemberModel {
|
||||||
|
id: Number
|
||||||
|
name: String
|
||||||
|
band: BandModel
|
||||||
|
image: String
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ProductModel } from "./productModel"
|
import { ShowModel } from "./showModel"
|
||||||
|
|
||||||
export class OrderItemModel {
|
export class OrderItemModel {
|
||||||
orderId: number = -1
|
orderId: number = -1
|
||||||
quantity: number = 1
|
quantity: number = 1
|
||||||
orderPrice: number = 0
|
orderPrice: number = 0
|
||||||
product: ProductModel
|
product: ShowModel
|
||||||
}
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { BrandModel } from "./brandModel"
|
|
||||||
import { CategoryModel } from "./categoryModel"
|
|
||||||
|
|
||||||
export class ProductModel {
|
|
||||||
id: number = 0
|
|
||||||
category: CategoryModel = new CategoryModel()
|
|
||||||
brand: BrandModel = new BrandModel()
|
|
||||||
name: string = ""
|
|
||||||
description: string = ""
|
|
||||||
price: number = 0
|
|
||||||
discount: number = 0
|
|
||||||
rating: number = 1
|
|
||||||
inStock: number = 0
|
|
||||||
offered: boolean = true
|
|
||||||
specs: Array<string> = []
|
|
||||||
images: Array<string> = [""]
|
|
||||||
}
|
|
||||||
9
software/src/data/models/ratingModel.ts
Normal file
9
software/src/data/models/ratingModel.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { AccountModel } from "./accountModel"
|
||||||
|
import { BandModel } from "./bandModel"
|
||||||
|
|
||||||
|
export class RatingModel {
|
||||||
|
id: Number
|
||||||
|
account: AccountModel
|
||||||
|
rating: Number
|
||||||
|
band: BandModel
|
||||||
|
}
|
||||||
9
software/src/data/models/showModel.ts
Normal file
9
software/src/data/models/showModel.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { LocationModel } from "./locationModel"
|
||||||
|
|
||||||
|
export class ShowModel {
|
||||||
|
id: Number
|
||||||
|
inStock: Number
|
||||||
|
date: String
|
||||||
|
price: Number
|
||||||
|
location: LocationModel
|
||||||
|
}
|
||||||
10
software/src/data/models/tourModel.ts
Normal file
10
software/src/data/models/tourModel.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { BandModel } from "./bandModel"
|
||||||
|
import { ShowModel } from "./showModel"
|
||||||
|
|
||||||
|
export class TourModel {
|
||||||
|
id: Number
|
||||||
|
name: String
|
||||||
|
band: BandModel
|
||||||
|
offered: Boolean
|
||||||
|
shows: Array<ShowModel>
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user