diff --git a/src/modules/product/controllers/food.controller.ts b/src/modules/product/controllers/product.controller.ts similarity index 100% rename from src/modules/product/controllers/food.controller.ts rename to src/modules/product/controllers/product.controller.ts diff --git a/src/modules/product/crone/food.crone.ts b/src/modules/product/crone/product.crone.ts similarity index 100% rename from src/modules/product/crone/food.crone.ts rename to src/modules/product/crone/product.crone.ts diff --git a/src/modules/product/dto/create-food.dto.ts b/src/modules/product/dto/create-product.dto.ts similarity index 100% rename from src/modules/product/dto/create-food.dto.ts rename to src/modules/product/dto/create-product.dto.ts diff --git a/src/modules/product/dto/find-foods.dto.ts b/src/modules/product/dto/find-products.dto.ts similarity index 100% rename from src/modules/product/dto/find-foods.dto.ts rename to src/modules/product/dto/find-products.dto.ts diff --git a/src/modules/product/dto/update-food.dto.ts b/src/modules/product/dto/update-product.dto.ts similarity index 100% rename from src/modules/product/dto/update-food.dto.ts rename to src/modules/product/dto/update-product.dto.ts diff --git a/src/modules/product/entities/food.entity.ts b/src/modules/product/entities/food.entity.ts index 489d6f4..50a5fbe 100644 --- a/src/modules/product/entities/food.entity.ts +++ b/src/modules/product/entities/food.entity.ts @@ -1,58 +1,17 @@ -import { Cascade, Collection, Entity, Index, ManyToOne, OneToMany, Property, OneToOne } from '@mikro-orm/core'; -import { Category } from './category.entity'; +import { Entity, Property } from '@mikro-orm/core'; 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' }) -@Index({ properties: ['restaurant', 'isActive'] }) -@Index({ properties: ['category', 'isActive'] }) -@Index({ properties: ['isActive'] }) 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(this); - - @OneToOne(() => Inventory, { - mappedBy: 'product', - nullable: true, - }) - inventory?: Inventory; - - @OneToMany(() => Favorite, favorite => favorite.product) - favorites = new Collection(this); @Property({ nullable: true }) title?: string; @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 }) isActive: boolean = true; @@ -60,18 +19,5 @@ export class product extends BaseEntity { @Property({ type: 'json', nullable: true }) 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; } diff --git a/src/modules/product/entities/product.entity.ts b/src/modules/product/entities/product.entity.ts new file mode 100644 index 0000000..ee86bdc --- /dev/null +++ b/src/modules/product/entities/product.entity.ts @@ -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[]; + + +} diff --git a/src/modules/product/interface/food.interface.ts b/src/modules/product/interface/product.interface.ts similarity index 100% rename from src/modules/product/interface/food.interface.ts rename to src/modules/product/interface/product.interface.ts diff --git a/src/modules/product/food.module.ts b/src/modules/product/product.module.ts similarity index 100% rename from src/modules/product/food.module.ts rename to src/modules/product/product.module.ts diff --git a/src/modules/product/providers/food.service.ts b/src/modules/product/providers/product.service.ts similarity index 100% rename from src/modules/product/providers/food.service.ts rename to src/modules/product/providers/product.service.ts diff --git a/src/modules/product/repositories/food.repository.ts b/src/modules/product/repositories/product.repository.ts similarity index 100% rename from src/modules/product/repositories/food.repository.ts rename to src/modules/product/repositories/product.repository.ts