This commit is contained in:
2026-02-18 22:15:50 +03:30
parent 84270ccb46
commit 3afcd2e4b3
8 changed files with 135 additions and 19 deletions
+59 -1
View File
@@ -1 +1,59 @@
export class CreateRequestDto {}
import {
IsString,
IsInt,
IsArray,
IsNumber,
IsNotEmpty,
ArrayMinSize,
IsOptional,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IAttachment, IField } from '../interface/request.interface';
export class CreateRequestItemDto {
@IsString()
@IsNotEmpty()
@ApiProperty()
productId: string;
@IsNumber()
@ApiProperty()
quantity: number;
@ApiPropertyOptional({ type: 'array', items: { type: 'object', properties: { fieldId: { type: 'number' }, value: { type: 'string' } } } })
@IsOptional()
@IsArray()
attributes?: IField[];
@ApiPropertyOptional()
@IsOptional()
@IsString()
description?: string;
@ApiPropertyOptional({ type: 'array', items: { type: 'object', properties: { type: { type: 'string' }, url: { type: 'string' } } } })
@IsOptional()
@IsArray()
attachments?: IAttachment[];
}
export class CreateRequestDto {
@IsArray()
@ApiProperty({
isArray: true,
type: [CreateRequestItemDto],
example: [
{
productId: '01ARZ3NDEKTSV4RRFFQ69G5FAV',
quantity: 100,
attributes: [{ fieldId: 1, value: 'blue' }],
attachments: [{ url: '', type: 'image' }],
description: 'توضیحات',
},
],
})
@IsNotEmpty()
@ArrayMinSize(1, { message: 'At least one item is required' })
@Type(() => CreateRequestItemDto)
items: CreateRequestItemDto[];
}