This commit is contained in:
2026-02-19 12:36:26 +03:30
parent 4953bed42c
commit 75a4154f90
9 changed files with 143 additions and 1020 deletions
+28 -128
View File
@@ -1,146 +1,46 @@
import {
IsString,
IsInt, IsArray, IsNumber,
IsInt,
IsNotEmpty,
ArrayMinSize,
IsOptional,
IsBoolean,
IsEnum,
IsDateString
} from 'class-validator';
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IAttachment, IField, OrderItemStatusEnum } from '../interface/order.interface';
export class CreateOrderItemAsUserDto {
@IsString()
@ApiProperty()
productId: string;
@ApiProperty()
@IsNumber()
quantity: number
@ApiProperty({ enum: OrderItemStatusEnum })
@IsEnum(() => OrderItemStatusEnum)
status: OrderItemStatusEnum
@ApiProperty()
@IsArray()
attributes: IField[]
@ApiPropertyOptional({ example: 'توضیحات' })
@IsString()
description: string
@ApiPropertyOptional({ example: [] })
@IsArray()
attachments: { url: string, type: string }[]
}
export class CreateOrderItemDtoAsAdmin extends CreateOrderItemAsUserDto {
// @ApiPropertyOptional({ example: [] })
// @IsArray()
// printAttributes?: IField[]
// @ApiPropertyOptional({ example: [] })
// @IsArray()
// printAttachments?: IAttachment[]
@IsInt()
@ApiProperty()
designerId: string;
@ApiProperty()
@IsNumber()
unitPrice: number
@ApiProperty()
@IsNumber()
discount: number
@ApiPropertyOptional()
@IsString()
adminDescription: string
@ApiPropertyOptional()
@IsDateString()
confirmedAt: string
}
export class CreateOrderAsUSerDto {
@IsArray()
@ApiProperty({
isArray: true, type: [CreateOrderItemAsUserDto],
example: [
{
productId: 'sd4',
quantity: 100,
attributes: [
{
attributeId: 1,
value: 'string | boolean| number'
}
],
attachments: [
{ url: '', type: '' }
],
description: ''
}
]
})
@IsNotEmpty()
@ArrayMinSize(1, { message: 'At least one item is required' })
@Type(() => CreateOrderItemAsUserDto)
items: CreateOrderItemAsUserDto[];
}
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class CreateOrderAsAdminDto {
@ApiProperty({ example: '' })
@IsString()
@IsNotEmpty()
userId: string
userId: string;
@IsArray()
@ApiProperty({
isArray: true, type: [CreateOrderItemDtoAsAdmin], example: [
{
productId: 1,
designerId: '',
attachments: [{ url: '', type: '' }],
quantity: 100,
attributes: [{ fieldId: 10, value: 'blue' }],
unitPrice: 150000,
discount: 20000,
adminDescription: '',
description: 'توضیحات کاربر',
}
]
})
@IsNotEmpty()
@ArrayMinSize(1, { message: 'At least one product is required' })
@Type(() => CreateOrderItemDtoAsAdmin)
items: CreateOrderItemDtoAsAdmin[];
@ApiProperty({})
@ApiProperty()
@IsString()
@IsOptional()
paymentMethod: string
@IsNotEmpty()
typeId: string;
@ApiProperty({})
@IsBoolean()
enableTax: boolean
@ApiProperty({})
@ApiProperty({ description: 'Estimated days to complete' })
@IsInt()
estimatedDays: number
estimatedDays: number;
@ApiPropertyOptional()
@IsOptional()
@IsString()
productId?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
title?: string;
}
export class CreateOrderItemDtoAsAdmin {
@ApiProperty()
@IsString()
@IsNotEmpty()
productId: string;
@ApiPropertyOptional()
@IsOptional()
@IsInt()
quantity?: number;
}
@@ -1,16 +0,0 @@
import { IsArray, } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IField } from '../interface/order.interface';
export class CreatePrintFormDto {
@ApiPropertyOptional({
example: [{
fieldId: 10, value: ''
}]
})
@IsArray()
printAttributes?: IField[]
}
@@ -1,7 +0,0 @@
import { PartialType } from '@nestjs/swagger';
import { CreateOrderItemAsUserDto, CreateOrderItemDtoAsAdmin } from './create-order.dto';
export class UpdateOrderItemDtoAsUser extends PartialType(CreateOrderItemAsUserDto) { }
export class UpdateOrderItemDtoAsAdmin extends PartialType(CreateOrderItemDtoAsAdmin) { }