93 lines
2.3 KiB
TypeScript
93 lines
2.3 KiB
TypeScript
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
|
|
import { QueueOrder } from '../../domain/entities/order.entity';
|
|
import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
import { QueueTicket } from '../../domain/entities/ticket.entity';
|
|
import { QueueItem } from '../../domain/entities/queue-item.entity';
|
|
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
|
|
|
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
|
|
|
@Entity(TABLE_NAME.QUEUE_ORDER)
|
|
export class QueueOrderModel
|
|
extends BaseCoreModel<QueueOrderModel>
|
|
implements QueueOrder
|
|
{
|
|
@Column('varchar')
|
|
code: string;
|
|
|
|
@Column('varchar', { nullable: true })
|
|
customer: string;
|
|
|
|
@Column('varchar', { nullable: true })
|
|
phone: string;
|
|
|
|
@Column('varchar', { nullable: false })
|
|
transaction_id: string;
|
|
|
|
@OneToMany(() => QueueTicketModel, (model) => model.order, {
|
|
cascade: true,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
tickets: QueueTicket[];
|
|
|
|
@Column({ type: 'bigint' })
|
|
date: number;
|
|
}
|
|
|
|
@Entity(TABLE_NAME.QUEUE_TICKET)
|
|
export class QueueTicketModel
|
|
extends BaseCoreModel<QueueTicketModel>
|
|
implements QueueTicket
|
|
{
|
|
@Column('varchar')
|
|
code: string;
|
|
|
|
@Column('varchar', { nullable: true })
|
|
customer: string;
|
|
|
|
@Column('varchar', { nullable: true })
|
|
phone: string;
|
|
|
|
@ManyToOne(() => QueueOrderModel, (model) => model.tickets, {
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'order_id' })
|
|
order: QueueOrder;
|
|
|
|
@Column({ type: 'bigint' })
|
|
date: number;
|
|
|
|
@OneToMany(() => QueueItemModel, (model) => model.ticket, {
|
|
cascade: true,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
items: QueueItem[];
|
|
}
|
|
|
|
@Entity(TABLE_NAME.QUEUE_ITEM)
|
|
export class QueueItemModel
|
|
extends BaseCoreModel<QueueItemModel>
|
|
implements QueueItem
|
|
{
|
|
@ManyToOne(() => QueueTicketModel, (model) => model.items, {
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'ticket_id' })
|
|
ticket: QueueTicket;
|
|
|
|
@Column('varchar')
|
|
item_id: string;
|
|
|
|
@ManyToOne(() => ItemModel)
|
|
@JoinColumn({ name: 'item_id' })
|
|
item: ItemEntity;
|
|
|
|
@Column('int')
|
|
qty: number;
|
|
}
|