food==. product
This commit is contained in:
@@ -1,58 +1,17 @@
|
|||||||
import { Cascade, Collection, Entity, Index, ManyToOne, OneToMany, Property, OneToOne } from '@mikro-orm/core';
|
import { Entity, Property } from '@mikro-orm/core';
|
||||||
import { Category } from './category.entity';
|
|
||||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { Restaurant } from '../../../modules/restaurants/entities/restaurant.entity';
|
|
||||||
import { Review } from 'src/modules/review/entities/review.entity';
|
|
||||||
import { Inventory } from 'src/modules/inventory/entities/inventory.entity';
|
|
||||||
import { MealType } from '../interface/product.interface';
|
|
||||||
import { Favorite } from './favorite.entity';
|
|
||||||
|
|
||||||
@Entity({ tableName: 'products' })
|
@Entity({ tableName: 'products' })
|
||||||
@Index({ properties: ['restaurant', 'isActive'] })
|
|
||||||
@Index({ properties: ['category', 'isActive'] })
|
|
||||||
@Index({ properties: ['isActive'] })
|
|
||||||
export class product extends BaseEntity {
|
export class product extends BaseEntity {
|
||||||
@ManyToOne(() => Restaurant)
|
|
||||||
restaurant: Restaurant;
|
|
||||||
|
|
||||||
@ManyToOne(() => Category)
|
|
||||||
category: Category;
|
|
||||||
|
|
||||||
@OneToMany(() => Review, review => review.product, { cascade: [Cascade.ALL], orphanRemoval: true })
|
|
||||||
reviews = new Collection<Review>(this);
|
|
||||||
|
|
||||||
@OneToOne(() => Inventory, {
|
|
||||||
mappedBy: 'product',
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
inventory?: Inventory;
|
|
||||||
|
|
||||||
@OneToMany(() => Favorite, favorite => favorite.product)
|
|
||||||
favorites = new Collection<Favorite>(this);
|
|
||||||
|
|
||||||
@Property({ nullable: true })
|
@Property({ nullable: true })
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
||||||
@Property({ type: 'text', nullable: true })
|
@Property({ type: 'text', nullable: true })
|
||||||
desc?: string;
|
linkUrl?: string;
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
|
||||||
content?: string[];
|
|
||||||
|
|
||||||
@Property({ type: 'decimal', precision: 10, scale: 2, nullable: true })
|
|
||||||
price?: number;
|
|
||||||
|
|
||||||
@Property({ type: 'int', nullable: true })
|
|
||||||
order?: number;
|
|
||||||
|
|
||||||
@Property({ type: 'int', nullable: true })
|
|
||||||
prepareTime?: number; // in minutes
|
|
||||||
|
|
||||||
@Property({ type: 'jsonb', default: [] })
|
|
||||||
weekDays: number[] = [0, 1, 2, 3, 4, 5, 6];
|
|
||||||
|
|
||||||
@Property({ type: 'jsonb', default: [] })
|
|
||||||
mealTypes: MealType[] = [];
|
|
||||||
|
|
||||||
@Property({ type: 'boolean', default: true })
|
@Property({ type: 'boolean', default: true })
|
||||||
isActive: boolean = true;
|
isActive: boolean = true;
|
||||||
@@ -60,18 +19,5 @@ export class product extends BaseEntity {
|
|||||||
@Property({ type: 'json', nullable: true })
|
@Property({ type: 'json', nullable: true })
|
||||||
images?: string[];
|
images?: string[];
|
||||||
|
|
||||||
@Property({ type: 'boolean', default: false })
|
|
||||||
inPlaceServe: boolean = false;
|
|
||||||
|
|
||||||
@Property({ type: 'boolean', default: false })
|
|
||||||
pickupServe: boolean = false;
|
|
||||||
|
|
||||||
@Property({ type: 'float', default: null })
|
|
||||||
score?: number | null = null;
|
|
||||||
|
|
||||||
@Property({ type: 'float', default: 0 })
|
|
||||||
discount: number = 0;
|
|
||||||
|
|
||||||
@Property({ type: 'boolean', default: false })
|
|
||||||
isSpecialOffer: boolean = false;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { Entity, Property } from '@mikro-orm/core';
|
||||||
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
|
|
||||||
|
|
||||||
|
@Entity({ tableName: 'products' })
|
||||||
|
export class product extends BaseEntity {
|
||||||
|
|
||||||
|
|
||||||
|
@Property({ nullable: true })
|
||||||
|
title?: string;
|
||||||
|
|
||||||
|
@Property({ type: 'text', nullable: true })
|
||||||
|
linkUrl?: string;
|
||||||
|
|
||||||
|
|
||||||
|
@Property({ type: 'boolean', default: true })
|
||||||
|
isActive: boolean = true;
|
||||||
|
|
||||||
|
@Property({ type: 'json', nullable: true })
|
||||||
|
images?: string[];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user