diff --git a/src/shared/dto/composant.dto.ts b/src/shared/dto/composant.dto.ts new file mode 100644 index 0000000..f638d6d --- /dev/null +++ b/src/shared/dto/composant.dto.ts @@ -0,0 +1,63 @@ +import { IsString, IsOptional, IsNumber } from 'class-validator'; +import { Transform } from 'class-transformer'; + +export class CreateComposantDto { + @IsString() + name: string; + + @IsOptional() + @IsString() + machineId?: string; + + @IsOptional() + @IsString() + parentComposantId?: string; + + @IsOptional() + @IsString() + reference?: string; + + @IsOptional() + @IsString() + prestataire?: string; + + @IsOptional() + @Transform(({ value }) => value === '' ? null : value) + @IsNumber({}, { message: 'prix must be a valid number' }) + prix?: number | null; + + @IsOptional() + @IsString() + emplacement?: string; + + @IsOptional() + @IsString() + typeComposantId?: string; +} + +export class UpdateComposantDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + reference?: string; + + @IsOptional() + @IsString() + prestataire?: string; + + @IsOptional() + @Transform(({ value }) => value === '' ? null : value) + @IsNumber({}, { message: 'prix must be a valid number' }) + prix?: number | null; + + @IsOptional() + @IsString() + emplacement?: string; + + @IsOptional() + @IsString() + typeComposantId?: string; +} \ No newline at end of file diff --git a/src/shared/dto/custom-field.dto.ts b/src/shared/dto/custom-field.dto.ts new file mode 100644 index 0000000..6d0f536 --- /dev/null +++ b/src/shared/dto/custom-field.dto.ts @@ -0,0 +1,29 @@ +import { IsString, IsOptional, IsNotEmpty } from 'class-validator'; + +export class CreateCustomFieldValueDto { + @IsString() + @IsNotEmpty() + customFieldId: string; + + @IsString() + @IsNotEmpty() + value: string; + + @IsOptional() + @IsString() + machineId?: string; + + @IsOptional() + @IsString() + composantId?: string; + + @IsOptional() + @IsString() + pieceId?: string; +} + +export class UpdateCustomFieldValueDto { + @IsOptional() + @IsString() + value?: string; +} \ No newline at end of file diff --git a/src/shared/dto/document.dto.ts b/src/shared/dto/document.dto.ts new file mode 100644 index 0000000..864f83c --- /dev/null +++ b/src/shared/dto/document.dto.ts @@ -0,0 +1,52 @@ +import { IsString, IsOptional, IsNumber } from 'class-validator'; + +export class CreateDocumentDto { + @IsString() + name: string; + + @IsString() + filename: string; + + @IsString() + path: string; + + @IsString() + mimeType: string; + + @IsNumber() + size: number; + + @IsOptional() + @IsString() + machineId?: string; + + @IsOptional() + @IsString() + composantId?: string; + + @IsOptional() + @IsString() + pieceId?: string; +} + +export class UpdateDocumentDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + filename?: string; + + @IsOptional() + @IsString() + path?: string; + + @IsOptional() + @IsString() + mimeType?: string; + + @IsOptional() + @IsNumber() + size?: number; +} \ No newline at end of file diff --git a/src/shared/dto/machine.dto.ts b/src/shared/dto/machine.dto.ts new file mode 100644 index 0000000..bb1cf47 --- /dev/null +++ b/src/shared/dto/machine.dto.ts @@ -0,0 +1,55 @@ +import { IsString, IsOptional, IsNumber, IsDecimal } from 'class-validator'; + +export class CreateMachineDto { + @IsString() + name: string; + + @IsString() + siteId: string; + + @IsOptional() + @IsString() + reference?: string; + + @IsOptional() + @IsString() + prestataire?: string; + + @IsOptional() + @IsDecimal() + prix?: string; + + @IsOptional() + @IsString() + emplacement?: string; + + @IsOptional() + @IsString() + typeMachineId?: string; +} + +export class UpdateMachineDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + reference?: string; + + @IsOptional() + @IsString() + prestataire?: string; + + @IsOptional() + @IsDecimal() + prix?: string; + + @IsOptional() + @IsString() + emplacement?: string; + + @IsOptional() + @IsString() + typeMachineId?: string; +} \ No newline at end of file diff --git a/src/shared/dto/piece.dto.ts b/src/shared/dto/piece.dto.ts new file mode 100644 index 0000000..10be8ea --- /dev/null +++ b/src/shared/dto/piece.dto.ts @@ -0,0 +1,63 @@ +import { IsString, IsOptional, IsNumber } from 'class-validator'; +import { Transform } from 'class-transformer'; + +export class CreatePieceDto { + @IsString() + name: string; + + @IsOptional() + @IsString() + machineId?: string; + + @IsOptional() + @IsString() + composantId?: string; + + @IsOptional() + @IsString() + reference?: string; + + @IsOptional() + @IsString() + prestataire?: string; + + @IsOptional() + @Transform(({ value }) => value === '' ? null : value) + @IsNumber({}, { message: 'prix must be a valid number' }) + prix?: number | null; + + @IsOptional() + @IsString() + emplacement?: string; + + @IsOptional() + @IsString() + typePieceId?: string; +} + +export class UpdatePieceDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + reference?: string; + + @IsOptional() + @IsString() + prestataire?: string; + + @IsOptional() + @Transform(({ value }) => value === '' ? null : value) + @IsNumber({}, { message: 'prix must be a valid number' }) + prix?: number | null; + + @IsOptional() + @IsString() + emplacement?: string; + + @IsOptional() + @IsString() + typePieceId?: string; +} \ No newline at end of file diff --git a/src/shared/dto/site.dto.ts b/src/shared/dto/site.dto.ts new file mode 100644 index 0000000..d04155b --- /dev/null +++ b/src/shared/dto/site.dto.ts @@ -0,0 +1,20 @@ +import { IsString, IsOptional } from 'class-validator'; + +export class CreateSiteDto { + @IsString() + name: string; + + @IsOptional() + @IsString() + description?: string; +} + +export class UpdateSiteDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + description?: string; +} \ No newline at end of file diff --git a/src/shared/dto/type.dto.ts b/src/shared/dto/type.dto.ts new file mode 100644 index 0000000..07337dc --- /dev/null +++ b/src/shared/dto/type.dto.ts @@ -0,0 +1,164 @@ +import { IsString, IsOptional, IsArray, IsObject, IsBoolean, IsEnum } from 'class-validator'; + +export enum CustomFieldType { + TEXT = 'text', + NUMBER = 'number', + SELECT = 'select', + BOOLEAN = 'boolean', + DATE = 'date' +} + +export class CreateCustomFieldDto { + @IsString() + name: string; + + @IsEnum(CustomFieldType) + type: CustomFieldType; + + @IsOptional() + @IsBoolean() + required?: boolean; + + @IsOptional() + @IsString() + defaultValue?: string; + + @IsOptional() + @IsArray() + options?: string[]; // Pour les champs de type SELECT +} + +export class UpdateCustomFieldDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsEnum(CustomFieldType) + type?: CustomFieldType; + + @IsOptional() + @IsBoolean() + required?: boolean; + + @IsOptional() + @IsString() + defaultValue?: string; + + @IsOptional() + @IsArray() + options?: string[]; +} + +export class CreateTypeMachineDto { + @IsString() + name: string; + + @IsOptional() + @IsString() + description?: string; + + @IsOptional() + @IsString() + category?: string; + + @IsOptional() + @IsString() + maintenanceFrequency?: string; + + @IsOptional() + @IsArray() + components?: any[]; + + @IsOptional() + @IsArray() + machinePieces?: string[]; + + @IsOptional() + @IsArray() + customFields?: CreateCustomFieldDto[]; +} + +export class UpdateTypeMachineDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + description?: string; + + @IsOptional() + @IsString() + category?: string; + + @IsOptional() + @IsString() + maintenanceFrequency?: string; + + @IsOptional() + @IsArray() + components?: any[]; + + @IsOptional() + @IsArray() + machinePieces?: string[]; + + @IsOptional() + @IsArray() + customFields?: CreateCustomFieldDto[]; +} + +export class CreateTypeComposantDto { + @IsString() + name: string; + + @IsOptional() + @IsString() + description?: string; + + @IsOptional() + @IsArray() + customFields?: CreateCustomFieldDto[]; +} + +export class UpdateTypeComposantDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + description?: string; + + @IsOptional() + @IsArray() + customFields?: CreateCustomFieldDto[]; +} + +export class CreateTypePieceDto { + @IsString() + name: string; + + @IsOptional() + @IsString() + description?: string; + + @IsOptional() + @IsArray() + customFields?: CreateCustomFieldDto[]; +} + +export class UpdateTypePieceDto { + @IsOptional() + @IsString() + name?: string; + + @IsOptional() + @IsString() + description?: string; + + @IsOptional() + @IsArray() + customFields?: CreateCustomFieldDto[]; +} \ No newline at end of file