@startuml event-최종승인및배포 !theme mono title Event Service - 최종 승인 및 Distribution Service 동기 호출 (UFR-EVENT-050) participant "EventController" as Controller <> participant "EventService" as Service <> participant "EventRepository" as Repo <> participant "Redis Cache" as Cache <> database "Event DB" as DB <> participant "Distribution Service" as DistSvc <> participant "Kafka Producer" as Kafka <> note over Controller: POST /api/events/{id}/publish Controller -> Service: publishEvent(eventDraftId, userId, selectedChannels) activate Service Service -> Repo: findById(eventDraftId) activate Repo Repo -> DB: SELECT * FROM event_drafts\nWHERE id = ? AND user_id = ? activate DB DB --> Repo: EventDraft deactivate DB Repo --> Service: EventDraft entity deactivate Repo Service -> Service: validateOwnership(userId, eventDraft) Service -> Service: validatePublishReady() note right: 발행 준비 검증:\n- 목적 선택 완료\n- AI 추천 선택 완료\n- 콘텐츠 선택 완료\n- 배포 채널 최소 1개 Service -> Repo: updateStatus(eventDraftId, APPROVED) activate Repo Repo -> DB: UPDATE event_drafts SET\nstatus = 'APPROVED',\napproved_at = NOW()\nWHERE id = ? activate DB DB --> Repo: OK deactivate DB Repo --> Service: EventDraft entity deactivate Repo Service -> Kafka: publish(EventCreated,\n{eventId, userId, title,\nobjective, createdAt}) activate Kafka note right: Kafka Event Topic:\nevent-topic Kafka --> Service: ACK deactivate Kafka Service -> DistSvc: POST /api/distribution/distribute\n{eventId, channels, content} activate DistSvc note right: 동기 호출 (Circuit Breaker 적용)\nTimeout: 70초 DistSvc -> DistSvc: distributeToChannels(eventId, channels) note right: 다중 채널 병렬 배포:\n- 우리동네TV\n- 링고비즈\n- 지니TV\n- Instagram\n- Naver Blog\n- Kakao Channel DistSvc --> Service: DistributionResponse\n{distributionId, channelResults} deactivate DistSvc Service -> Repo: updateStatus(eventDraftId, ACTIVE) activate Repo Repo -> DB: UPDATE event_drafts SET\nstatus = 'ACTIVE',\npublished_at = NOW()\nWHERE id = ? activate DB DB --> Repo: OK deactivate DB Repo --> Service: Event entity deactivate Repo Service -> Cache: delete("purpose:" + userId) activate Cache note right: 캐시 무효화 Cache --> Service: OK deactivate Cache Service --> Controller: PublishResponse\n{eventId, status: ACTIVE,\ndistributionResults} deactivate Service Controller --> Client: 200 OK\n{eventId, distributionResults} note over Controller, Kafka: Distribution Service는\n배포 완료 후 Kafka에\nDistributionCompleted\n이벤트 발행 @enduml