-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fes 107 create the quick api to create menu item for testing (#105)
* change db, create dtos and route * add logic to create menu item --------- Co-authored-by: NHT <[email protected]>
- Loading branch information
1 parent
05092a9
commit 4cebb8e
Showing
12 changed files
with
641 additions
and
11 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/database/migrations/1712321852821-UpdateMenuItemCreationProcess.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class UpdateMenuItemCreationProcess1712321852821 | ||
implements MigrationInterface | ||
{ | ||
name = 'UpdateMenuItemCreationProcess1712321852821'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE Menu_Item | ||
ADD COLUMN standard_price INT NULL AFTER units_sold; | ||
`); | ||
|
||
await queryRunner.query(`ALTER TABLE Menu_Item | ||
ADD COLUMN min_price INT NULL AFTER standard_price, | ||
ADD COLUMN max_price INT NULL AFTER min_price; | ||
`); | ||
|
||
await queryRunner.query(`ALTER TABLE Menu_Item_Attribute_Value | ||
ADD COLUMN price_variance INT NULL AFTER note, | ||
ADD COLUMN is_standard TINYINT NULL AFTER price_variance;`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE Menu_Item | ||
DROP COLUMN standard_price; | ||
`); | ||
|
||
await queryRunner.query(`ALTER TABLE Menu_Item | ||
DROP COLUMN max_price, | ||
DROP COLUMN min_price; | ||
`); | ||
|
||
await queryRunner.query(`ALTER TABLE Menu_Item_Attribute_Value | ||
DROP COLUMN is_standard, | ||
DROP COLUMN price_variance;`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Entity, PrimaryColumn, CreateDateColumn } from 'typeorm'; | ||
|
||
@Entity('Menu_Item_Attribute_Ingredient') | ||
export class MenuItemAttributeIngredient { | ||
@PrimaryColumn() | ||
public attribute_id: number; | ||
|
||
@PrimaryColumn() | ||
public ingredient_id: number; | ||
|
||
@CreateDateColumn({ | ||
type: 'datetime', | ||
nullable: false, | ||
unique: false, | ||
default: () => 'CURRENT_TIMESTAMP', | ||
}) | ||
public created_at: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
enum IsoLangCode { | ||
VIE = 'vie', | ||
ENG = 'eng', | ||
} | ||
|
||
export interface RecipeItem { | ||
ingredient_id: number; | ||
|
||
quantity: number; | ||
|
||
unit_id: number; | ||
} | ||
|
||
interface PortionCustomizationValue { | ||
value: number; | ||
|
||
unit_id: number; | ||
|
||
price_variance: number; //Can be negative | ||
|
||
is_standard: boolean; | ||
} | ||
|
||
export interface PortionCustomizationItem { | ||
name: string; | ||
|
||
corresponding_ingredients: number[]; | ||
|
||
value: PortionCustomizationValue[]; | ||
} | ||
|
||
export interface PriceSetting { | ||
standard: number; | ||
min: number; | ||
max: number; | ||
} | ||
export interface TasteCustomizationItem { | ||
taste_id: string; | ||
taste_values: string[]; | ||
} | ||
|
||
export class CreateMenuItemRequest { | ||
restaurant_id: number; //REQUIRED | ||
|
||
ISO_language_code: IsoLangCode; //REQUIRED | ||
|
||
name: string; //REQUIRED | ||
|
||
short_name: string; //REQUIRED | ||
|
||
description: string; //REQUIRED | ||
|
||
main_cooking_method: string; //REQUIRED | ||
|
||
preparing_time_minutes: number; //REQUIRED | ||
|
||
cooking_time_minutes: number; //REQUIRED | ||
|
||
is_vegetarian: boolean; //REQUIRED | ||
|
||
res_category_id: number; //REQUIRED | ||
|
||
image_url: string; //REQUIRED | ||
|
||
other_image_url: string[]; //OPTIONAL | ||
|
||
basic_customization: string[]; //REQUIRED | ||
|
||
recipe: RecipeItem[]; //REQUIRED | ||
|
||
portion_customization: PortionCustomizationItem[]; //REQUIRED | ||
|
||
price: PriceSetting; //REQUIRED | ||
|
||
taste_customization: TasteCustomizationItem[]; //REQUIRED | ||
|
||
packaging: number[]; //REQUIRED | ||
|
||
secret_key: string; //OPTIONAL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class CreateMenuItemResponse { | ||
message: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.