package com.zioinfo.mall.gateway;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;

/** Mock 이메일 발송기 (기본). 외부 호출 0 — 로그만 남기고 성공 반환. */
@Slf4j
@Component
@ConditionalOnProperty(name = "mall.email.provider", havingValue = "mock", matchIfMissing = true)
public class MockEmailSender implements EmailSender {

    @Override
    public Map<String, Object> send(String toEmail, String subject, String htmlBody) {
        log.info("[MOCK-EMAIL] to={} subject={}", toEmail, subject);
        Map<String, Object> out = new LinkedHashMap<>();
        out.put("provider", "mock");
        out.put("messageId", "MOCK-EMAIL-" + UUID.randomUUID().toString().substring(0, 10));
        out.put("status", "SENT");
        return out;
    }

    @Override
    public String provider() {
        return "mock";
    }
}
