update order
This commit is contained in:
@@ -7,12 +7,12 @@ import {
|
||||
IsBoolean,
|
||||
IsEnum
|
||||
} from 'class-validator';
|
||||
import { ApiPropertyOptional, ApiProperty, OmitType } from '@nestjs/swagger';
|
||||
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IAttribute, OrderStatusEnum } from '../interface/order.interface';
|
||||
import { IAttachment, IField, OrderStatusEnum } from '../interface/order.interface';
|
||||
|
||||
export class CreateOrderItemDtoAsAdmin {
|
||||
|
||||
export class CreateOrderItemAsUserDto {
|
||||
@IsInt()
|
||||
@ApiProperty()
|
||||
productId: number;
|
||||
@@ -23,7 +23,7 @@ export class CreateOrderItemDtoAsAdmin {
|
||||
|
||||
@ApiProperty()
|
||||
@IsArray()
|
||||
attributes: IAttribute[]
|
||||
attributes: IField[]
|
||||
|
||||
@ApiPropertyOptional({ example: 'توضیحات' })
|
||||
@IsString()
|
||||
@@ -33,6 +33,22 @@ export class CreateOrderItemDtoAsAdmin {
|
||||
@IsArray()
|
||||
attachments: { url: string, type: string }[]
|
||||
|
||||
|
||||
}
|
||||
|
||||
export class CreateOrderItemDtoAsAdmin extends CreateOrderItemAsUserDto {
|
||||
@ApiPropertyOptional({ example: [] })
|
||||
@IsArray()
|
||||
print?: IField[]
|
||||
|
||||
@ApiPropertyOptional({ example: [] })
|
||||
@IsArray()
|
||||
printAttachments?: IAttachment[]
|
||||
|
||||
@IsInt()
|
||||
@ApiProperty()
|
||||
designerId: string;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
unitPrice: number
|
||||
@@ -43,10 +59,7 @@ export class CreateOrderItemDtoAsAdmin {
|
||||
|
||||
}
|
||||
|
||||
export class CreateOrderItemAsUserDto extends OmitType(CreateOrderItemDtoAsAdmin, ['unitPrice', 'discount']) { }
|
||||
|
||||
|
||||
export class CreateOrderDto {
|
||||
export class CreateOrderAsUSerDto {
|
||||
@IsArray()
|
||||
@ApiProperty({
|
||||
isArray: true, type: [CreateOrderItemAsUserDto], example: [
|
||||
@@ -55,8 +68,8 @@ export class CreateOrderDto {
|
||||
quantity: 100,
|
||||
attributes: [
|
||||
{
|
||||
attributeId:1,
|
||||
value:'string | boolean| number'
|
||||
attributeId: 1,
|
||||
value: 'string | boolean| number'
|
||||
}
|
||||
],
|
||||
attachments: [
|
||||
@@ -72,37 +85,6 @@ export class CreateOrderDto {
|
||||
items: CreateOrderItemAsUserDto[];
|
||||
}
|
||||
|
||||
export class CreateOrderItemDto {
|
||||
|
||||
@IsInt()
|
||||
@ApiProperty()
|
||||
productId: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
quantity: number
|
||||
|
||||
@ApiProperty()
|
||||
@IsArray()
|
||||
attributes: IAttribute[]
|
||||
|
||||
@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: '' })
|
||||
@@ -112,9 +94,12 @@ export class CreateOrderAsAdminDto {
|
||||
|
||||
@IsArray()
|
||||
@ApiProperty({
|
||||
isArray: true, type: [CreateOrderItemDto], example: [
|
||||
isArray: true, type: [CreateOrderItemDtoAsAdmin], example: [
|
||||
{
|
||||
productId: 1,
|
||||
designerId: '',
|
||||
print: [{ fieldId: '', value: '' }],
|
||||
printAttachments: [{ url: '', type: '' }],
|
||||
quantity: 100,
|
||||
attributesValues: []
|
||||
}
|
||||
@@ -122,19 +107,9 @@ export class CreateOrderAsAdminDto {
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@ArrayMinSize(1, { message: 'At least one product is required' })
|
||||
@Type(() => CreateOrderItemDto)
|
||||
items: CreateOrderItemDto[];
|
||||
@Type(() => CreateOrderItemDtoAsAdmin)
|
||||
items: CreateOrderItemDtoAsAdmin[];
|
||||
|
||||
@ApiProperty({ example: '' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
designerId: string
|
||||
|
||||
@ApiProperty({ example: '' })
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsNotEmpty()
|
||||
attachments: string[]
|
||||
|
||||
@ApiProperty({})
|
||||
@IsString()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OmitType, PartialType } from '@nestjs/swagger';
|
||||
import { CreateOrderAsAdminDto, CreateOrderDto } from './create-order.dto';
|
||||
import { CreateOrderAsAdminDto } from './create-order.dto';
|
||||
|
||||
export class UpdateOrderDtoAsAdmin extends PartialType(OmitType(CreateOrderAsAdminDto, 'items' as any)) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user