This commit is contained in:
2025-11-18 12:55:37 +03:30
parent 81fa0ca2b9
commit c24775d091
6 changed files with 538 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsArray, ValidateNested, IsNumber, Min } from 'class-validator';
import { Type } from 'class-transformer';
export class CartItemDto {
@ApiProperty({ description: 'Food ID', example: '01KA9Q52JSWFY98TW3HZY6XEVZ' })
@IsNotEmpty()
@IsString()
foodId!: string;
@ApiProperty({ description: 'Quantity of the food item', example: 2, minimum: 1 })
@IsNotEmpty()
@IsNumber()
@Min(1)
quantity!: number;
}
export class CreateCartDto {
@ApiProperty({
description: 'List of cart items',
type: [CartItemDto],
example: [{ foodId: '01KA9Q52JSWFY98TW3HZY6XEVZ', quantity: 2 }],
})
@IsNotEmpty()
@IsArray()
@ValidateNested({ each: true })
@Type(() => CartItemDto)
items!: CartItemDto[];
}
+9
View File
@@ -0,0 +1,9 @@
import { PartialType, ApiProperty } from '@nestjs/swagger';
import { CreateCartDto, CartItemDto } from './create-cart.dto';
export class UpdateCartItemDto extends PartialType(CartItemDto) {}
export class UpdateCartDto {
@ApiProperty({ description: 'List of cart items to update', type: [UpdateCartItemDto], required: false })
items?: UpdateCartItemDto[];
}