mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 18:56:22 +00:00
updated product model dtos
This commit is contained in:
@ -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;
|
||||
}
|
@ -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[];
|
||||
}
|
@ -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[];
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
import { BaseProductModelDto } from './base-product-model.dto';
|
||||
|
||||
export class DeleteProductModelDto extends BaseProductModelDto {}
|
@ -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';
|
||||
|
@ -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[];
|
||||
}
|
@ -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[];
|
||||
}
|
Reference in New Issue
Block a user