refactor food
This commit is contained in:
@@ -1,6 +1,18 @@
|
|||||||
import { IsBoolean, IsOptional, IsString, IsNumber, IsArray, IsNotEmpty, IsEnum } from 'class-validator';
|
|
||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
|
import {
|
||||||
|
ArrayUnique,
|
||||||
|
IsArray,
|
||||||
|
IsBoolean,
|
||||||
|
IsEnum,
|
||||||
|
IsInt,
|
||||||
|
IsNotEmpty,
|
||||||
|
IsNumber,
|
||||||
|
IsOptional,
|
||||||
|
IsString,
|
||||||
|
Max,
|
||||||
|
Min,
|
||||||
|
} from 'class-validator';
|
||||||
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import { MealType } from '../interface/food.interface';
|
import { MealType } from '../interface/food.interface';
|
||||||
|
|
||||||
export class CreateFoodDto {
|
export class CreateFoodDto {
|
||||||
@@ -9,36 +21,6 @@ export class CreateFoodDto {
|
|||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
categoryId: string;
|
categoryId: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: false })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
breakfast?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: false })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
tue?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: false })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
wed?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: false })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
thu?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: false })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
fri?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
@ApiPropertyOptional({ example: 'قرمه سبزی' })
|
@ApiPropertyOptional({ example: 'قرمه سبزی' })
|
||||||
@@ -57,71 +39,35 @@ export class CreateFoodDto {
|
|||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@IsNumber({}, { each: true })
|
@ArrayUnique()
|
||||||
|
@IsInt({ each: true })
|
||||||
|
@Min(0, { each: true })
|
||||||
|
@Max(6, { each: true })
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiPropertyOptional({ type: [Number] })
|
@ApiPropertyOptional({ type: [Number], example: [0, 1, 2, 3, 4, 5, 6] })
|
||||||
weekDays?: number[];
|
weekDays?: number[];
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
|
@ArrayUnique()
|
||||||
@IsEnum(MealType, { each: true })
|
@IsEnum(MealType, { each: true })
|
||||||
@ApiPropertyOptional({ enum: MealType, isArray: true })
|
@ApiPropertyOptional({ enum: MealType, isArray: true })
|
||||||
mealTypes?: MealType[];
|
mealTypes?: MealType[];
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@Min(0)
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiPropertyOptional({ example: 120000 })
|
@ApiPropertyOptional({ example: 120000 })
|
||||||
price?: number;
|
price?: number;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsInt()
|
||||||
|
@Min(0)
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiPropertyOptional({ example: 15 })
|
@ApiPropertyOptional({ example: 15 })
|
||||||
prepareTime?: number;
|
prepareTime?: number;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: true })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
sat?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: true })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
sun?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: true })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
mon?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: false })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
noon?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
@ApiPropertyOptional({ example: true })
|
|
||||||
@Type(() => Boolean)
|
|
||||||
dinner?: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsNumber()
|
|
||||||
@Type(() => Number)
|
|
||||||
@ApiPropertyOptional({ example: 10 })
|
|
||||||
stock?: number;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsNumber()
|
|
||||||
@Type(() => Number)
|
|
||||||
@ApiPropertyOptional({ example: 10 })
|
|
||||||
stockDefault?: number;
|
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
@ApiPropertyOptional({ example: true })
|
@ApiPropertyOptional({ example: true })
|
||||||
@@ -148,12 +94,14 @@ export class CreateFoodDto {
|
|||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@Min(0)
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiPropertyOptional({ example: 0 })
|
@ApiPropertyOptional({ example: 0 })
|
||||||
discount?: number;
|
discount?: number;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@Min(0)
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiPropertyOptional({ example: 0 })
|
@ApiPropertyOptional({ example: 0 })
|
||||||
score?: number;
|
score?: number;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { OrderStatus } from '../interface/order-status';
|
|||||||
import { PaymentMethodEnum, PaymentStatusEnum } from '../../payments/interface/payment';
|
import { PaymentMethodEnum, PaymentStatusEnum } from '../../payments/interface/payment';
|
||||||
import { Cart } from '../../cart/interfaces/cart.interface';
|
import { Cart } from '../../cart/interfaces/cart.interface';
|
||||||
import { PaymentMethod } from '../../payments/entities/payment-method.entity';
|
import { PaymentMethod } from '../../payments/entities/payment-method.entity';
|
||||||
// import { PaymentGatewayService } from '../../payments/services/payment-gateway.service.tss';
|
|
||||||
import { PaymentsService } from '../../payments/services/payments.service';
|
import { PaymentsService } from '../../payments/services/payments.service';
|
||||||
import { DeliveryMethodEnum } from '../../delivery/interface/delivery';
|
import { DeliveryMethodEnum } from '../../delivery/interface/delivery';
|
||||||
import { Delivery } from '../../delivery/entities/delivery.entity';
|
import { Delivery } from '../../delivery/entities/delivery.entity';
|
||||||
|
|||||||
Reference in New Issue
Block a user