From bb63ac08e37182c520552eed5d93c01658155e65 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Fri, 20 Dec 2024 08:18:25 +0400 Subject: [PATCH] updated product model dtos --- .../base-product-model.dto.ts | 12 ++ .../create-product-model.dto.ts | 39 +++++++ .../create-space-product-model.dto.ts | 106 ------------------ .../delete-product-model.dto.ts | 3 + .../dtos/product-model-dtos/index.ts | 5 +- .../product-model-modification.dto.ts | 34 ++++++ .../update-product-model.dto.ts | 32 ++++++ 7 files changed, 124 insertions(+), 107 deletions(-) create mode 100644 src/space-model/dtos/product-model-dtos/base-product-model.dto.ts create mode 100644 src/space-model/dtos/product-model-dtos/create-product-model.dto.ts delete mode 100644 src/space-model/dtos/product-model-dtos/create-space-product-model.dto.ts create mode 100644 src/space-model/dtos/product-model-dtos/delete-product-model.dto.ts create mode 100644 src/space-model/dtos/product-model-dtos/product-model-modification.dto.ts create mode 100644 src/space-model/dtos/product-model-dtos/update-product-model.dto.ts diff --git a/src/space-model/dtos/product-model-dtos/base-product-model.dto.ts b/src/space-model/dtos/product-model-dtos/base-product-model.dto.ts new file mode 100644 index 0000000..4a27559 --- /dev/null +++ b/src/space-model/dtos/product-model-dtos/base-product-model.dto.ts @@ -0,0 +1,12 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { IsNotEmpty, IsString } from 'class-validator'; + +export class BaseProductModelDto { + @ApiProperty({ + description: 'ID of the product model', + example: 'product-uuid', + }) + @IsNotEmpty() + @IsString() + productModelUuid: string; +} diff --git a/src/space-model/dtos/product-model-dtos/create-product-model.dto.ts b/src/space-model/dtos/product-model-dtos/create-product-model.dto.ts new file mode 100644 index 0000000..947fc59 --- /dev/null +++ b/src/space-model/dtos/product-model-dtos/create-product-model.dto.ts @@ -0,0 +1,39 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { + IsNotEmpty, + IsString, + IsArray, + ValidateNested, + IsInt, + ArrayNotEmpty, +} from 'class-validator'; +import { Type } from 'class-transformer'; +import { CreateProductItemModelDto } from '../create-space-product-item-model.dto'; + +export class CreateProductModelDto { + @ApiProperty({ + description: 'ID of the product associated with the model', + example: 'product-uuid', + }) + @IsNotEmpty() + @IsString() + productUuid: string; + + @ApiProperty({ + description: 'Number of products in the model', + example: 3, + }) + @IsNotEmpty() + @IsInt() + productCount: number; + + @ApiProperty({ + description: 'Specific names for each product item', + type: [CreateProductItemModelDto], + }) + @IsArray() + @ArrayNotEmpty() + @ValidateNested({ each: true }) + @Type(() => CreateProductItemModelDto) + items: CreateProductItemModelDto[]; +} diff --git a/src/space-model/dtos/product-model-dtos/create-space-product-model.dto.ts b/src/space-model/dtos/product-model-dtos/create-space-product-model.dto.ts deleted file mode 100644 index 2ff2a7f..0000000 --- a/src/space-model/dtos/product-model-dtos/create-space-product-model.dto.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { - IsNotEmpty, - IsString, - IsArray, - ValidateNested, - IsInt, - ArrayNotEmpty, - IsOptional, -} from 'class-validator'; -import { Type } from 'class-transformer'; -import { CreateProductItemModelDto } from '../create-space-product-item-model.dto'; - -export class CreateProductModelDto { - @ApiProperty({ - description: 'ID of the product associated with the model', - example: 'product-uuid', - }) - @IsNotEmpty() - @IsString() - productUuid: string; - - @ApiProperty({ - description: 'Number of products in the model', - example: 3, - }) - @IsNotEmpty() - @IsInt() - productCount: number; - - @ApiProperty({ - description: 'Specific names for each product item', - type: [CreateProductItemModelDto], - }) - @IsArray() - @ArrayNotEmpty() - @ValidateNested({ each: true }) - @Type(() => CreateProductItemModelDto) - items: CreateProductItemModelDto[]; -} - -export class UpdateSpaceProductModelDto { - @ApiProperty({ - description: 'ID of the product model', - example: 'product-uuid', - }) - @IsNotEmpty() - @IsString() - productModelUuid: string; - - @ApiProperty({ - description: 'Number of products in the model', - example: 3, - }) - @IsNotEmpty() - @IsInt() - productCount: number; - - @ApiProperty({ - description: 'Specific names for each product item', - type: [CreateProductItemModelDto], - }) - @IsArray() - @ArrayNotEmpty() - @ValidateNested({ each: true }) - @Type(() => CreateProductItemModelDto) - items: CreateProductItemModelDto[]; -} - -export class DeleteProductModelDto { - @ApiProperty({ - description: 'ID of the product model', - example: 'product-uuid', - }) - @IsNotEmpty() - @IsString() - productModelUuid: string; -} - -export class ModifyProductModelDto { - @IsArray() - @ApiProperty({ - description: 'Create the product model ', - type: [CreateProductModelDto], - }) - @ValidateNested({ each: true }) - @IsOptional() - add?: CreateProductModelDto[]; - - @IsArray() - @ApiProperty({ - description: 'Update the product model ', - type: [UpdateSpaceProductModelDto], - }) - @ValidateNested({ each: true }) - @IsOptional() - update?: UpdateSpaceProductModelDto[]; - - @IsArray() - @ApiProperty({ - description: 'Update the product model ', - type: [UpdateSpaceProductModelDto], - }) - @IsOptional() - delete?: DeleteProductModelDto[]; -} diff --git a/src/space-model/dtos/product-model-dtos/delete-product-model.dto.ts b/src/space-model/dtos/product-model-dtos/delete-product-model.dto.ts new file mode 100644 index 0000000..5653c8d --- /dev/null +++ b/src/space-model/dtos/product-model-dtos/delete-product-model.dto.ts @@ -0,0 +1,3 @@ +import { BaseProductModelDto } from './base-product-model.dto'; + +export class DeleteProductModelDto extends BaseProductModelDto {} diff --git a/src/space-model/dtos/product-model-dtos/index.ts b/src/space-model/dtos/product-model-dtos/index.ts index 3fdad23..b2dbd90 100644 --- a/src/space-model/dtos/product-model-dtos/index.ts +++ b/src/space-model/dtos/product-model-dtos/index.ts @@ -1 +1,4 @@ -export * from './create-space-product-model.dto'; +export * from './create-product-model.dto'; +export * from './delete-product-model.dto'; +export * from './update-product-model.dto'; +export * from './product-model-modification.dto'; diff --git a/src/space-model/dtos/product-model-dtos/product-model-modification.dto.ts b/src/space-model/dtos/product-model-dtos/product-model-modification.dto.ts new file mode 100644 index 0000000..8bf9133 --- /dev/null +++ b/src/space-model/dtos/product-model-dtos/product-model-modification.dto.ts @@ -0,0 +1,34 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { IsArray, ValidateNested, IsOptional } from 'class-validator'; + +import { CreateProductModelDto } from './create-product-model.dto'; +import { DeleteProductModelDto } from './delete-product-model.dto'; +import { UpdateProductModelDto } from './update-product-model.dto'; + +export class ProductModelModificationDto { + @IsArray() + @ApiProperty({ + description: 'Create the product model ', + type: [CreateProductModelDto], + }) + @ValidateNested({ each: true }) + @IsOptional() + add?: CreateProductModelDto[]; + + @IsArray() + @ApiProperty({ + description: 'Update the product model ', + type: [UpdateProductModelDto], + }) + @ValidateNested({ each: true }) + @IsOptional() + update?: UpdateProductModelDto[]; + + @IsArray() + @ApiProperty({ + description: 'Delete the product model ', + type: [DeleteProductModelDto], + }) + @IsOptional() + delete?: DeleteProductModelDto[]; +} diff --git a/src/space-model/dtos/product-model-dtos/update-product-model.dto.ts b/src/space-model/dtos/product-model-dtos/update-product-model.dto.ts new file mode 100644 index 0000000..0f0d64d --- /dev/null +++ b/src/space-model/dtos/product-model-dtos/update-product-model.dto.ts @@ -0,0 +1,32 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; +import { + IsNotEmpty, + IsString, + IsInt, + IsArray, + ArrayNotEmpty, + ValidateNested, +} from 'class-validator'; +import { CreateProductItemModelDto } from '../create-space-product-item-model.dto'; +import { BaseProductModelDto } from './base-product-model.dto'; + +export class UpdateProductModelDto extends BaseProductModelDto { + @ApiProperty({ + description: 'Number of products in the model', + example: 3, + }) + @IsNotEmpty() + @IsInt() + productCount: number; + + @ApiProperty({ + description: 'Specific names for each product item', + type: [CreateProductItemModelDto], + }) + @IsArray() + @ArrayNotEmpty() + @ValidateNested({ each: true }) + @Type(() => CreateProductItemModelDto) + items: CreateProductItemModelDto[]; +}