creat order bug

This commit is contained in:
2026-01-17 17:58:49 +03:30
parent 60fbf26d97
commit e07075a7c5
10 changed files with 129 additions and 119 deletions
+36 -15
View File
@@ -1,20 +1,12 @@
import { IsString, IsOptional, IsBoolean, IsInt, Min, IsArray, IsNumber } from 'class-validator';
import {
IsString, IsOptional, IsBoolean,
IsInt, Min, IsArray, IsNumber,
IsNotEmpty,
ArrayMinSize
} from 'class-validator';
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
export class CreateOrderDto {
@IsArray()
@ApiProperty({ isArray: true })
items: CreateOrderItemDto[];
@IsString()
content: string
@IsArray()
@IsString({ each: true })
attachments: string[]
}
export class CreateOrderItemDto {
@IsInt()
@@ -22,8 +14,37 @@ export class CreateOrderItemDto {
productId: bigint;
@ApiProperty()
@IsNumber()
quantity: number
@ApiProperty()
@IsArray()
attributesValues: string[]
}
}
export class CreateOrderDto {
@IsArray()
@ApiProperty({
isArray: true, type: [CreateOrderItemDto], example: [
{
productId: 1,
quantity: 100,
attributesValues: []
}
]
})
@IsNotEmpty()
@ArrayMinSize(1, { message: 'At least one product is required' })
@Type(() => CreateOrderItemDto)
items: CreateOrderItemDto[];
@ApiPropertyOptional({ example: 'توضیحات' })
@IsString()
content: string
@ApiPropertyOptional({ example: [] })
@IsArray()
@IsString({ each: true })
attachments: string[]
}