update order
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
import {
|
||||
IsArray, IsNumber,
|
||||
IsNotEmpty,
|
||||
ArrayMinSize
|
||||
} from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class InvoiceItemDto {
|
||||
@IsNumber()
|
||||
@ApiProperty()
|
||||
productId: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsArray()
|
||||
attributesValues: string[]
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
quantity: number
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
unitPrice: number
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
discount: number
|
||||
|
||||
}
|
||||
|
||||
export class AddOrderItemDto {
|
||||
@IsArray()
|
||||
@ApiProperty({
|
||||
isArray: true, type: [InvoiceItemDto], example: [
|
||||
{
|
||||
orderItemId: 1,
|
||||
unitPrice: 100,
|
||||
}
|
||||
]
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@ArrayMinSize(1, { message: 'At least one product is required' })
|
||||
@Type(() => InvoiceItemDto)
|
||||
items: InvoiceItemDto[];
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
import {
|
||||
IsString,
|
||||
IsInt, IsArray, IsNumber,
|
||||
IsNotEmpty,
|
||||
ArrayMinSize,
|
||||
IsMobilePhone,
|
||||
IsOptional,
|
||||
IsBoolean,
|
||||
IsEnum
|
||||
} from 'class-validator';
|
||||
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { OrderStatusEnum } from '../interface/order.interface';
|
||||
|
||||
export class CreateOrderItemDto {
|
||||
|
||||
@IsInt()
|
||||
@ApiProperty()
|
||||
productId: bigint;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
quantity: number
|
||||
|
||||
@ApiProperty()
|
||||
@IsArray()
|
||||
attributesValues: string[]
|
||||
|
||||
@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: '' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
userId: string
|
||||
|
||||
@IsArray()
|
||||
@ApiProperty({
|
||||
isArray: true, type: [CreateOrderItemDto], example: [
|
||||
{
|
||||
productId: 1,
|
||||
quantity: 100,
|
||||
attributesValues: []
|
||||
}
|
||||
]
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@ArrayMinSize(1, { message: 'At least one product is required' })
|
||||
@Type(() => CreateOrderItemDto)
|
||||
items: CreateOrderItemDto[];
|
||||
|
||||
@ApiProperty({ example: '' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
designerId: string
|
||||
|
||||
@ApiProperty({ example: '' })
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsNotEmpty()
|
||||
attachments: string[]
|
||||
|
||||
@ApiProperty({})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
paymentMethod: string
|
||||
|
||||
@ApiProperty({})
|
||||
@IsBoolean()
|
||||
enableTax: Boolean
|
||||
|
||||
@ApiProperty({})
|
||||
@IsInt()
|
||||
estimatedDays: number
|
||||
|
||||
@ApiProperty({ enum: OrderStatusEnum })
|
||||
@IsEnum(OrderStatusEnum)
|
||||
status: OrderStatusEnum
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@ import {
|
||||
IsString,
|
||||
IsInt, IsArray, IsNumber,
|
||||
IsNotEmpty,
|
||||
ArrayMinSize
|
||||
ArrayMinSize,
|
||||
IsOptional,
|
||||
IsBoolean,
|
||||
IsEnum
|
||||
} from 'class-validator';
|
||||
import { ApiPropertyOptional, ApiProperty, OmitType } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IAttribute, OrderStatusEnum } from '../interface/order.interface';
|
||||
|
||||
export class CreateOrderItemDtoAsAdmin {
|
||||
|
||||
@@ -16,10 +20,10 @@ export class CreateOrderItemDtoAsAdmin {
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
quantity: number
|
||||
// TODO : find a way to save attribute and value
|
||||
|
||||
@ApiProperty()
|
||||
@IsArray()
|
||||
attributesValues: string[]
|
||||
attributes: IAttribute[]
|
||||
|
||||
@ApiPropertyOptional({ example: 'توضیحات' })
|
||||
@IsString()
|
||||
@@ -49,7 +53,12 @@ export class CreateOrderDto {
|
||||
{
|
||||
productId: 1,
|
||||
quantity: 100,
|
||||
attributesValues: [],
|
||||
attributes: [
|
||||
{
|
||||
attributeId:1,
|
||||
value:'string | boolean| number'
|
||||
}
|
||||
],
|
||||
attachments: [
|
||||
{ url: '', type: '' }
|
||||
],
|
||||
@@ -63,3 +72,85 @@ export class CreateOrderDto {
|
||||
items: CreateOrderItemAsUserDto[];
|
||||
}
|
||||
|
||||
export class CreateOrderItemDto {
|
||||
|
||||
@IsInt()
|
||||
@ApiProperty()
|
||||
productId: bigint;
|
||||
|
||||
@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: '' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
userId: string
|
||||
|
||||
@IsArray()
|
||||
@ApiProperty({
|
||||
isArray: true, type: [CreateOrderItemDto], example: [
|
||||
{
|
||||
productId: 1,
|
||||
quantity: 100,
|
||||
attributesValues: []
|
||||
}
|
||||
]
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@ArrayMinSize(1, { message: 'At least one product is required' })
|
||||
@Type(() => CreateOrderItemDto)
|
||||
items: CreateOrderItemDto[];
|
||||
|
||||
@ApiProperty({ example: '' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
designerId: string
|
||||
|
||||
@ApiProperty({ example: '' })
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsNotEmpty()
|
||||
attachments: string[]
|
||||
|
||||
@ApiProperty({})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
paymentMethod: string
|
||||
|
||||
@ApiProperty({})
|
||||
@IsBoolean()
|
||||
enableTax: Boolean
|
||||
|
||||
@ApiProperty({})
|
||||
@IsInt()
|
||||
estimatedDays: number
|
||||
|
||||
@ApiProperty({ enum: OrderStatusEnum })
|
||||
@IsEnum(OrderStatusEnum)
|
||||
status: OrderStatusEnum
|
||||
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
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 UpdateOrderDtoAsUser {
|
||||
@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[];
|
||||
|
||||
|
||||
@ApiProperty()
|
||||
@IsBoolean()
|
||||
enableTax: boolean
|
||||
|
||||
|
||||
@ApiPropertyOptional({ example: [] })
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
attachments: string[]
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { OmitType, PartialType } from '@nestjs/swagger';
|
||||
import { CreateOrderAsAdminDto, CreateOrderDto } from './create-order.dto';
|
||||
|
||||
export class UpdateOrderDtoAsAdmin extends PartialType(OmitType(CreateOrderAsAdminDto, 'items' as any)) { }
|
||||
|
||||
Reference in New Issue
Block a user