cart
This commit is contained in:
@@ -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[];
|
||||
}
|
||||
@@ -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[];
|
||||
}
|
||||
Reference in New Issue
Block a user