Add ToursTable, update API documentation
This commit is contained in:
45
software/backend/models/ordering/order.model.ts
Normal file
45
software/backend/models/ordering/order.model.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Table, Column, Model, BelongsTo, ForeignKey, HasMany, BelongsToMany, Default } from 'sequelize-typescript';
|
||||
import { Account } from '../user/account.model';
|
||||
import { OrderItem } from './orderItem.model';
|
||||
import { Address } from '../user/address.model';
|
||||
import { Payment } from '../user/payment.model';
|
||||
|
||||
@Table({
|
||||
updatedAt: false,
|
||||
createdAt: 'orderedAt'
|
||||
})
|
||||
export class Order extends Model {
|
||||
@Column
|
||||
@ForeignKey(() => Account)
|
||||
accountId: number
|
||||
|
||||
@Column
|
||||
orderedAt: Date
|
||||
|
||||
@Default(1)
|
||||
@Column
|
||||
shippingProgress: number
|
||||
|
||||
@ForeignKey(() => Address)
|
||||
@Column
|
||||
addressId: number
|
||||
|
||||
@ForeignKey(() => Payment)
|
||||
@Column
|
||||
paymentId: number
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsTo(() => Account)
|
||||
account: Account
|
||||
|
||||
@BelongsTo(() => Address)
|
||||
address: Address
|
||||
|
||||
@BelongsTo(() => Payment)
|
||||
payment: Payment
|
||||
|
||||
@HasMany(() => OrderItem)
|
||||
orderItems: OrderItem[]
|
||||
}
|
||||
28
software/backend/models/ordering/orderItem.model.ts
Normal file
28
software/backend/models/ordering/orderItem.model.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Model, BelongsTo, Column, ForeignKey, HasMany, HasOne, Table } from "sequelize-typescript";
|
||||
import { Show } from "../acts/show.model";
|
||||
import { Order } from "./order.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class OrderItem extends Model {
|
||||
@Column
|
||||
@ForeignKey(() => Order)
|
||||
orderId: number
|
||||
|
||||
@Column
|
||||
quantity: number
|
||||
|
||||
@Column
|
||||
orderPrice: number
|
||||
|
||||
@Column
|
||||
@ForeignKey(() => Show)
|
||||
showId: number
|
||||
|
||||
|
||||
// Relations
|
||||
@BelongsTo(() => Order)
|
||||
order: Order
|
||||
|
||||
@BelongsTo(() => Show)
|
||||
product: Show
|
||||
}
|
||||
Reference in New Issue
Block a user