@startuml event-상세조회
!theme mono

title Event Service - 이벤트 상세 조회 (UFR-EVENT-060)

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>>

note over Controller: GET /api/events/{id}
Controller -> Service: getEventDetail(eventId, userId)
activate Service

Service -> Cache: get("event:" + eventId)
activate Cache

alt 캐시 히트
    Cache --> Service: Event data
    Service -> Service: validateAccess(userId, event)
    note right: 사용자 권한 검증
    Service --> Controller: EventDetailResponse

else 캐시 미스
    Cache --> Service: null
    deactivate Cache

    Service -> Repo: findById(eventId)
    activate Repo
    Repo -> DB: 이벤트 상세 정보 조회\n(이벤트ID로 이벤트 정보,\n경품 정보, 배포 이력을\nJOIN하여 함께 조회)
    activate DB
    note right: JOIN으로\n경품 정보 및\n배포 이력 조회
    DB --> Repo: Event with prizes and distributions
    deactivate DB
    Repo --> Service: Event entity (with relations)
    deactivate Repo

    Service -> Service: validateAccess(userId, event)

    Service -> Cache: set("event:" + eventId, event, TTL=5분)
    activate Cache
    Cache --> Service: OK
    deactivate Cache
end

Service --> Controller: EventDetailResponse\n{eventId, title, objective,\nprizes, period, status,\nchannels, distributionStatus,\ncreatedAt, publishedAt}
deactivate Service

Controller --> Client: 200 OK\n{event: {...},\nprizes: [...],\ndistributionStatus: {...}}

note over Controller, DB: 상세 정보 포함:\n- 기본 정보 (제목, 목적, 기간, 상태)\n- 경품 정보\n- 참여 방법\n- 배포 채널 현황\n- 실시간 통계 (Analytics Service)\n\nAnalytics 통계는\n별도 API 호출

@enduml
