create order as admn

This commit is contained in:
2026-01-19 17:41:49 +03:30
parent c7f5fdf241
commit e74ab1b573
4 changed files with 192 additions and 7 deletions
@@ -0,0 +1,66 @@
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
}