request
This commit is contained in:
@@ -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[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user