Files
negareh-api/src/modules/order/dto/create-order-as-admin.dto.ts
T
2026-01-26 12:21:04 +03:30

98 lines
1.9 KiB
TypeScript

import {
IsString,
IsInt, IsArray, IsNumber,
IsNotEmpty,
ArrayMinSize,
IsMobilePhone,
IsOptional,
IsBoolean,
IsEnum
} from 'class-validator';
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { OrderStatusEnum } from '../interface/order.interface';
export class CreateOrderItemDto {
@IsInt()
@ApiProperty()
productId: bigint;
@ApiProperty()
@IsNumber()
quantity: number
@ApiProperty()
@IsArray()
attributesValues: string[]
@ApiProperty()
@IsNumber()
unitPrice: number
@ApiProperty()
@IsNumber()
discount: number
@ApiPropertyOptional({ example: 'توضیحات' })
@IsString()
description: string
@ApiPropertyOptional({ example: [] })
@IsArray()
@IsString({ each: true })
attachments: { url: string, type: string }[]
}
export class CreateOrderAsAdminDto {
@ApiProperty({ example: '' })
@IsString()
@IsNotEmpty()
userId: 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[];
@ApiProperty({ example: '' })
@IsString()
@IsNotEmpty()
designerId: string
@ApiProperty({ example: '' })
@IsArray()
@IsString({ each: true })
@IsNotEmpty()
attachments: string[]
@ApiProperty({})
@IsString()
@IsOptional()
paymentMethod: string
@ApiProperty({})
@IsBoolean()
enableTax: Boolean
@ApiProperty({})
@IsInt()
estimatedDays: number
@ApiProperty({ enum: OrderStatusEnum })
@IsEnum(OrderStatusEnum)
status: OrderStatusEnum
}