package com.kt.event.content.infra.gateway.mock;

import com.kt.event.content.biz.domain.GeneratedImage;
import com.kt.event.content.biz.usecase.out.RedisAIDataReader;
import com.kt.event.content.biz.usecase.out.RedisImageWriter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * Mock Redis Gateway (테스트용)
 * 실제 Redis 연동 전까지 사용
 */
@Slf4j
@Component
@Profile({"local", "test"})
public class MockRedisGateway implements RedisAIDataReader, RedisImageWriter {

    private final Map<Long, Map<String, Object>> aiDataCache = new HashMap<>();

    // ========================================
    // RedisAIDataReader 구현
    // ========================================

    @Override
    public Optional<Map<String, Object>> getAIRecommendation(Long eventDraftId) {
        log.info("[MOCK] Redis에서 AI 추천 데이터 조회: eventDraftId={}", eventDraftId);

        // Mock 데이터 반환
        Map<String, Object> mockData = new HashMap<>();
        mockData.put("title", "테스트 이벤트 제목");
        mockData.put("description", "테스트 이벤트 설명");
        mockData.put("brandColor", "#FF5733");

        return Optional.of(mockData);
    }

    // ========================================
    // RedisImageWriter 구현
    // ========================================

    @Override
    public void cacheImages(Long eventDraftId, List<GeneratedImage> images, long ttlSeconds) {
        log.info("[MOCK] Redis에 이미지 캐싱: eventDraftId={}, count={}, ttl={}초",
                eventDraftId, images.size(), ttlSeconds);
    }
}
