kt-event-marketing/design/backend/sequence/inner/event-최종승인및배포.puml
2025-10-22 20:13:56 +09:00

76 lines
2.6 KiB
Plaintext

@startuml event-최종승인및배포
!theme mono
title Event Service - 최종 승인 및 Distribution Service 동기 호출 (UFR-EVENT-050)
participant "EventController" as Controller <<C>>
participant "EventService" as Service <<S>>
participant "EventRepository" as Repo <<R>>
participant "Redis Cache" as Cache <<E>>
database "Event DB" as DB <<E>>
participant "Distribution Service" as DistSvc <<E>>
participant "Kafka Producer" as Kafka <<E>>
note over Controller: POST /api/events/{id}/publish
Controller -> Service: publishEvent(eventDraftId, userId, selectedChannels)
activate Service
Service -> Repo: findById(eventDraftId)
activate Repo
Repo -> DB: 이벤트 초안 조회\n(초안ID와 사용자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: 이벤트 초안 상태 업데이트\n(상태를 APPROVED로,\n승인일시를 현재 시각으로 설정)
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: 이벤트 상태 업데이트\n(상태를 ACTIVE로,\n배포일시를 현재 시각으로 설정)
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