Trần Viết Sơn
feat: update order
95a812a
import {
BaseEntity,
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
OneToOne,
PrimaryGeneratedColumn,
Relation,
UpdateDateColumn,
} from 'typeorm';
import { BranchEntity } from './branch.entity.js';
import { UserEntity } from './user.entity.js';
import { OrderType } from '../common/enums/OrderType.enum.js';
import { OrderStatus } from '../common/enums/OrderStatus.enum.js';
import { OrderItemEntity } from './order-item.entity.js';
import { PaymentEntity } from './payment.entity.js';
@Entity('orders')
export class OrderEntity extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ nullable: true })
customer_id: string;
@ManyToOne(() => UserEntity, { nullable: true })
@JoinColumn({ name: 'customer_id' })
customer: Relation<UserEntity>;
@Column()
branch_id: string;
@ManyToOne(() => BranchEntity)
@JoinColumn({ name: 'branch_id' })
branch: Relation<BranchEntity>;
@Column({ nullable: true })
staff_id: string;
@ManyToOne(() => UserEntity, { nullable: true })
@JoinColumn({ name: 'staff_id' })
staff: Relation<UserEntity>;
@Column({ nullable: true })
table_number: number;
@Column({ nullable: true })
note: string;
@Column({ nullable: true })
rating: number;
@Column()
total_value: number;
@Column({ default: 0 })
order_type: number;
@Column({ default: 0 })
order_status: number;
@OneToMany(() => OrderItemEntity, (a) => a.order)
order_items: Relation<OrderItemEntity>[];
@Column({ nullable: true })
payment_id: number;
@OneToOne(() => PaymentEntity, (a) => a.order)
@JoinColumn({ name: 'payment_id' })
payment: Relation<PaymentEntity>;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
@DeleteDateColumn()
deleted_at: Date;
}