67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
import {
|
|
IsString, IsOptional, IsBoolean,
|
|
IsInt, Min, IsArray, IsNumber,
|
|
IsNotEmpty,
|
|
ArrayMinSize,
|
|
IsMobilePhone
|
|
} from 'class-validator';
|
|
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
|
|
export class CreateOrderItemDto {
|
|
|
|
@IsInt()
|
|
@ApiProperty()
|
|
productId: bigint;
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
quantity: number
|
|
|
|
@ApiProperty()
|
|
@IsArray()
|
|
attributesValues: string[]
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
unitPrice: number
|
|
}
|
|
|
|
export class CreateOrderAsAdminDto {
|
|
@ApiPropertyOptional({ example: 'توضیحات' })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@IsMobilePhone('fa-IR')
|
|
userPhone: string
|
|
|
|
@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[]
|
|
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
discount: number
|
|
}
|
|
|