Catalog Service — BR 5.1
Контракты
- Data Model — поля
yellow_threshold_minutes/red_threshold_minutesнаkitchen_stations, новая таблицаkds_franchise_settings- API — расширены
kitchen_stationsendpoints + 2 новых для KDS settings- Events — событие
catalog.kds_settings.updated- Бизнес-логика: Кухонные станции, Настройки KDS
Что делаем
Миграция Liquibase
-
src/main/resources/db/changelog/0XX_add_kds_settings.xml:- ALTER TABLE
kitchen_stationsADD COLUMNyellow_threshold_minutesinteger NOT NULL DEFAULT 5 - ALTER TABLE
kitchen_stationsADD COLUMNred_threshold_minutesinteger NOT NULL DEFAULT 0 - CHECK CONSTRAINT
yellow_threshold_minutes >= 0,red_threshold_minutes >= 0 - CREATE TABLE
kds_franchise_settings:- PK
(franchise_id), FK к franchises (cross-service ref, no DB FK — opaque) new_order_sound varchar(20) NOT NULL DEFAULT 'bell'new_order_repeat_seconds integer NOT NULL DEFAULT 30 CHECK BETWEEN 5 AND 120overdue_sound varchar(20) NOT NULL DEFAULT 'alarm'sound_volume smallint NOT NULL DEFAULT 80 CHECK BETWEEN 0 AND 100auto_logout_minutes integer NOT NULL DEFAULT 30 CHECK BETWEEN 5 AND 240created_at,updated_attimestamps
- PK
- Регистрация в
db.changelog-master.xml
- ALTER TABLE
Entities
-
KitchenStation— добавить поляyellowThresholdMinutes,redThresholdMinutes(Integer) - Новая
KdsFranchiseSettings:- PK
franchiseId(UUID) - Поля:
newOrderSound,newOrderRepeatSeconds,overdueSound,soundVolume,autoLogoutMinutes - Audit timestamps
- PK
Repositories
-
KdsFranchiseSettingsRepository extends JpaRepository<KdsFranchiseSettings, UUID>:Optional<KdsFranchiseSettings> findByFranchiseId(UUID)- В Service — auto-create если нет записи (default values)
Services
-
KitchenStationService.update(...)— расширить: если изменилисьyellow/red_threshold_minutes→ опубликоватьcatalog.kds_settings.updatedсkind=station_thresholds -
Новый
KdsFranchiseSettingsService:getOrCreate(franchiseId)— auto-create with defaultsupdate(franchiseId, partialDto)— partial update + публикация событияcatalog.kds_settings.updatedсkind=settings
Controllers
-
KitchenStationController— расширить:GET /kitchen-stationsResponse теперь включаетyellow_threshold_minutesиred_threshold_minutesPOST /kitchen-stationsRequest принимает (опционально) пороги, default 5/0PATCH /kitchen-stations/{id}Request принимает пороги, опубликовать событие если изменились
-
Новый
KdsAdminController:GET /admin/kds/settings— auto-create + return; permissionkds.settings.edit OR catalog.readPATCH /admin/kds/settings— partial update; permissionkds.settings.edit
KafkaPublisher
-
KdsEventPublisher:publishKdsSettingsUpdated(franchiseId, kind, kitchenStationId)— топикcatalog.kds_settings.updated, ключfranchise_id
Tests
- Unit:
KitchenStationServiceTest.update_publishesEventWhenThresholdsChangedKdsFranchiseSettingsServiceTest.getOrCreate_createsDefaultKdsFranchiseSettingsServiceTest.update_partial_publishesEvent
- Integration:
KdsAdminControllerIntegrationTest— get/patch с реальной БД и Kafka
Конфигурация
-
application.yml:app.kds.allowed-sounds-new-order: bell,chime,buzzer,marimba,digitalapp.kds.allowed-sounds-overdue: alarm,siren,bell-loud
Что НЕ делаем
- Не реализуем хранение/upload кастомных звуковых файлов — это BR 5.7
- Не делаем consumer на
catalog.kds_settings.updated— это P1 (pos-bff подпишется в BR 5.x для live-push)
Зависимости
- Permissions
kds.settings.editиcatalog.read— стандартный механизм auth (через JWT) — Catalog Service уже использует эту проверку