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:
@@ -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.",
|
||||
|
||||
Reference in New Issue
Block a user