refactor food

This commit is contained in:
2025-12-17 08:54:19 +03:30
parent ab1047e689
commit 1b42a0b4b4
2 changed files with 25 additions and 78 deletions
+25 -77
View File
@@ -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 {
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';
export class CreateFoodDto {
@@ -9,36 +21,6 @@ export class CreateFoodDto {
@ApiProperty()
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()
@IsString()
@ApiPropertyOptional({ example: 'قرمه سبزی' })
@@ -57,71 +39,35 @@ export class CreateFoodDto {
@IsOptional()
@IsArray()
@IsNumber({}, { each: true })
@ArrayUnique()
@IsInt({ each: true })
@Min(0, { each: true })
@Max(6, { each: true })
@Type(() => Number)
@ApiPropertyOptional({ type: [Number] })
@ApiPropertyOptional({ type: [Number], example: [0, 1, 2, 3, 4, 5, 6] })
weekDays?: number[];
@IsOptional()
@IsArray()
@ArrayUnique()
@IsEnum(MealType, { each: true })
@ApiPropertyOptional({ enum: MealType, isArray: true })
mealTypes?: MealType[];
@IsOptional()
@IsNumber()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 120000 })
price?: number;
@IsOptional()
@IsNumber()
@IsInt()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 15 })
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()
@IsBoolean()
@ApiPropertyOptional({ example: true })
@@ -148,12 +94,14 @@ export class CreateFoodDto {
@IsOptional()
@IsNumber()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 0 })
discount?: number;
@IsOptional()
@IsNumber()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 0 })
score?: number;
@@ -10,7 +10,6 @@ import { OrderStatus } from '../interface/order-status';
import { PaymentMethodEnum, PaymentStatusEnum } from '../../payments/interface/payment';
import { Cart } from '../../cart/interfaces/cart.interface';
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 { DeliveryMethodEnum } from '../../delivery/interface/delivery';
import { Delivery } from '../../delivery/entities/delivery.entity';