updated product model dtos

This commit is contained in:
hannathkadher
2024-12-20 08:18:25 +04:00
parent 7bfa0c32a8
commit bb63ac08e3
7 changed files with 124 additions and 107 deletions

View File

@ -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;
}

View File

@ -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[];
}

View File

@ -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[];
}

View File

@ -0,0 +1,3 @@
import { BaseProductModelDto } from './base-product-model.dto';
export class DeleteProductModelDto extends BaseProductModelDto {}

View File

@ -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';

View File

@ -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[];
}

View File

@ -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[];
}