feat: add product domain and machine integration

- extend Prisma schema with products, product constructs and link tables\n- introduce product service, DTOs and includes with constructeur support\n- integrate product selections across model type skeletons, composants, pièces and machines\n- validate product requirements when building machine skeletons and payloads
This commit is contained in:
Matthieu
2025-11-05 15:34:42 +01:00
parent e81f71e3e7
commit 6cf2b566ce
38 changed files with 2601 additions and 120 deletions

View File

@@ -36,6 +36,8 @@ export class CustomFieldsService {
return 'composantId' as const;
case CustomFieldEntityType.PIECE:
return 'pieceId' as const;
case CustomFieldEntityType.PRODUCT:
return 'productId' as const;
default:
throw new BadRequestException(
"Type d'entité de champ personnalisé invalide.",
@@ -114,6 +116,28 @@ export class CustomFieldsService {
valueKey: 'pieceId' as const,
};
}
case CustomFieldEntityType.PRODUCT: {
const product = await this.prisma.product.findUnique({
where: { id: entityId },
select: { typeProductId: true },
});
if (!product) {
throw new NotFoundException('Produit introuvable.');
}
if (!product.typeProductId) {
throw new BadRequestException(
'Le produit ne possède pas de type associé pour les champs personnalisés.',
);
}
return {
typeId: product.typeProductId,
customFieldTypeField: 'typeProductId' as const,
valueKey: 'productId' as const,
};
}
default:
throw new BadRequestException(
"Type d'entité de champ personnalisé invalide.",