@startuml event-추천안선택 !theme mono title Event Service - 선택한 AI 추천안 저장 (UFR-EVENT-040) participant "EventController" as Controller <> participant "EventService" as Service <> participant "EventRepository" as Repo <> participant "Redis Cache" as Cache <> database "Event DB" as DB <> note over Controller: PUT /api/events/drafts/{id}/recommendation Controller -> Service: updateEventRecommendation(eventDraftId, userId,\nselectedRecommendation) 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: validateRecommendation(selectedRecommendation) note right: 선택한 추천안\n유효성 검증 Service -> Service: applyRecommendation(eventDraft, selectedRecommendation) note right: 추천안 적용:\n- 이벤트 제목\n- 경품 정보\n- 참여 방법\n- 예상 비용\n- 예상 ROI Service -> Repo: update(eventDraft) activate Repo Repo -> DB: 이벤트 초안 업데이트\n(선택된 추천안 정보,\n제목, 경품, 참여방법,\n예상비용, 예상ROI,\n수정일시를 업데이트) activate DB DB --> Repo: OK deactivate DB Repo --> Service: EventDraft entity deactivate Repo Service -> Cache: delete("ai:recommendation:" + eventDraftId) activate Cache note right: Redis 캐시 무효화\n(AI 추천 결과) Cache --> Service: OK deactivate Cache Service --> Controller: EventRecommendationResponse\n{eventDraftId, selectedRecommendation} deactivate Service Controller --> Client: 200 OK\n{eventDraftId} note over Controller, Cache: 최종 선택된 추천안만\nEvent DB에 저장됨\n\nRedis에 저장된 3가지 추천안은\n선택 후 삭제됨 @enduml