BR 1.11 — Warehouse Service
Миграция
- Создать таблицу
ingredients(id, franchise_id, name, description, unit_of_measure, status, timestamps) - Добавить
ingredient_id(FK → ingredients, nullable) вrecipe_items - Добавить
semi_finished_product_id(nullable) вrecipe_items - Мигрировать данные из старого
ingredient_product_id→ingredient_id(создать ingredients из Catalog products type=ingredient) - Добавить CHECK constraint на
recipe_items: ровно одно из ingredient_id / semi_finished_product_id NOT NULL - Удалить
ingredient_product_idизrecipe_items - Заменить
ingredient_product_idнаingredient_id(FK, NOT NULL) вmodifier_tech_card_items - Обновить
unit_conversions: product_id → nullable, добавить ingredient_id с XOR constraint
Entity / DTO
- Создать
Ingrediententity - Создать
IngredientResponseDTO - Создать
CreateIngredientRequestDTO - Создать
UpdateIngredientRequestDTO - Обновить
RecipeItementity: ingredient_id + semi_finished_product_id - Обновить
ModifierTechCardItementity: ingredient_id - Обновить
RecipeItemResponse/ request DTOs - Обновить
UnitConversionentity: ingredient_id
Repository
- Создать
IngredientRepository(findByFranchiseId, findByFranchiseIdAndName, search) - Обновить
RecipeItemRepository— новые поля - Обновить
ModifierTechCardItemRepository - Обновить
UnitConversionRepository
Service
- Создать
IngredientService(CRUD + валидация: INGREDIENT_IN_USE при удалении/смене unit) - Обновить
RecipeItemService— ingredient_id / semi_finished_product_id логика - Обновить
TechCardService— маппинг ответов с новыми полями - Обновить
ModifierTechCardService— ingredient_id - Обновить
CostCalculationService— ingredient_id + semi_finished_product_id - Обновить
CatalogServiceClient— lookup semi_finished_product_name из Catalog
Controller
- Создать
IngredientController(GET/POST/PATCH/DELETE /ingredients) - Обновить
TechCardController— новые поля в items - Обновить
ModifierTechCardController— ingredient_id