@startuml event-콘텐츠선택 !theme mono title Content Service - 선택한 콘텐츠 저장 (UFR-CONT-020) actor Client participant "API Gateway" as Gateway participant "ContentController" as Controller <> participant "ContentService" as Service <> participant "EventRepository" as Repo <> participant "Redis Cache" as Cache <> database "Event DB" as DB <> note over Controller, Cache **UFR-CONT-020: 콘텐츠 선택 및 편집 저장** - 사용자가 3가지 이미지 스타일 중 하나 선택 - 선택된 이미지에 텍스트/색상 편집 적용 - 편집된 콘텐츠를 이벤트 초안에 저장 end note Client -> Gateway: PUT /api/content/{eventDraftId}/select\n{"userId": 123,\n"selectedImageUrl": "https://cdn.../fancy.png",\n"editedContent": {...}} activate Gateway Gateway -> Controller: PUT /api/content/{eventDraftId}/select activate Controller Controller -> Controller: 요청 검증\n(필수 필드, URL 유효성) Controller -> Service: updateEventContent(eventDraftId, userId,\nselectedImageUrl, editedContent) activate Service == 1단계: 이벤트 초안 조회 및 검증 == Service -> Repo: findById(eventDraftId) activate Repo Repo -> DB: 이벤트 초안 조회\n(초안ID로 조회) activate DB DB --> Repo: EventDraft 엔티티\n{목적, 추천안, 상태} deactivate DB Repo --> Service: EventDraft entity deactivate Repo Service -> Service: validateOwnership(userId, eventDraft) note right 소유권 검증: - 사용자ID와 초안 소유자 일치 확인 - 권한 없으면 403 Forbidden end note Service -> Service: validateImageUrl(selectedImageUrl) note right 이미지 URL 검증: - URL 형식 유효성 - CDN 경로 확인 - 이미지 존재 여부 end note == 2단계: 콘텐츠 편집 적용 == Service -> Service: applyContentEdits(eventDraft, editedContent) note right 편집 내용 적용: - 제목 텍스트 - 경품 정보 텍스트 - 참여 안내 텍스트 - 배경색 - 텍스트 색상 - 강조 색상 end note == 3단계: DB 저장 == Service -> Repo: update(eventDraft) activate Repo Repo -> DB: 이벤트 초안 업데이트\n(선택된 이미지 URL,\n편집된 제목/텍스트,\n배경색/텍스트색,\n수정일시 저장) activate DB DB --> Repo: 업데이트 완료 deactivate DB Repo --> Service: EventDraft entity deactivate Repo == 4단계: 캐시 무효화 == Service -> Cache: 캐시 삭제\nKey: content:image:{eventDraftId} activate Cache note right Redis 캐시 무효화: - 이미지 URL 캐시 삭제 - 선택 완료 후 불필요 end note Cache --> Service: 삭제 완료 deactivate Cache == 5단계: 응답 반환 == Service --> Controller: EventContentResponse\n{eventDraftId, selectedImageUrl,\neditedContent} deactivate Service Controller --> Gateway: 200 OK\n{"eventDraftId": 123,\n"status": "콘텐츠 선택 완료",\n"selectedImageUrl": "...",\n"editedContent": {...}} deactivate Controller Gateway --> Client: 200 OK\n콘텐츠 선택 완료 deactivate Gateway note over Client, Cache **저장 내용** - 선택된 이미지 URL - 편집된 텍스트 (제목, 경품 정보, 참여 안내) - 편집된 색상 (배경색, 텍스트색, 강조색) - 다음 단계: 최종 승인 및 배포 **성능 목표** - 응답 시간: 0.5초 이내 - DB 업데이트: 0.1초 - 캐시 삭제: 0.01초 end note @enduml