92 lines
1.6 KiB
TypeScript
92 lines
1.6 KiB
TypeScript
import {
|
|
IsArray, IsNumber,
|
|
IsNotEmpty,
|
|
ArrayMinSize,
|
|
IsBoolean,
|
|
IsString
|
|
} from 'class-validator';
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
|
|
export class ItemDto {
|
|
@IsNumber()
|
|
@ApiProperty()
|
|
orderItemId: number;
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
unitPrice: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
discount: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
quantity: number
|
|
|
|
}
|
|
|
|
export class NewItemDto {
|
|
@IsNumber()
|
|
@ApiProperty()
|
|
productId: number;
|
|
|
|
@ApiProperty()
|
|
@IsArray()
|
|
attributesValues: string[]
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
quantity: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
unitPrice: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
discount: number
|
|
|
|
}
|
|
|
|
export class UpdateOrderDto {
|
|
@IsArray()
|
|
@ApiProperty({
|
|
isArray: true, type: [ItemDto], example: [
|
|
{
|
|
orderItemId: 1,
|
|
unitPrice: 100,
|
|
}
|
|
]
|
|
})
|
|
@IsNotEmpty()
|
|
@ArrayMinSize(1, { message: 'At least one product is required' })
|
|
@Type(() => ItemDto)
|
|
items: ItemDto[];
|
|
|
|
@IsArray()
|
|
@ApiProperty({
|
|
isArray: true, type: [ItemDto], example: [
|
|
{
|
|
orderItemId: 1,
|
|
unitPrice: 100,
|
|
}
|
|
]
|
|
})
|
|
@Type(() => NewItemDto)
|
|
newItems: NewItemDto[];
|
|
|
|
@ApiProperty()
|
|
@IsBoolean()
|
|
enableTax: boolean
|
|
|
|
|
|
@ApiPropertyOptional({ example: [] })
|
|
@IsArray()
|
|
@IsString({ each: true })
|
|
attachments: string[]
|
|
|
|
}
|
|
|