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