2026-05-24 02:10:06 +09:00
|
|
|
package com.ga.external.message;
|
|
|
|
|
|
|
|
|
|
import com.ga.common.adapter.message.MessageAdapter;
|
|
|
|
|
import com.ga.common.adapter.message.MessageRequest;
|
|
|
|
|
import com.ga.common.adapter.message.MessageResponse;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2026-05-24 02:45:13 +09:00
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
2026-05-24 02:10:06 +09:00
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SMS / 카카오 알림톡 Mock 구현.
|
|
|
|
|
* <p>
|
2026-05-24 02:45:13 +09:00
|
|
|
* 활성 조건: app.adapter.message=mock (기본). 실제 SDK 통합 시 yml 값을 'toast' 등으로 바꾸면 본 빈은 비활성.
|
|
|
|
|
* 항상 성공 응답. phoneNumber 는 뒷 4자리 외 마스킹.
|
2026-05-24 02:10:06 +09:00
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Component
|
2026-05-24 02:45:13 +09:00
|
|
|
@ConditionalOnProperty(prefix = "app.adapter", name = "message", havingValue = "mock", matchIfMissing = true)
|
2026-05-24 02:10:06 +09:00
|
|
|
public class MockMessageAdapter implements MessageAdapter {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MessageResponse send(MessageRequest request) {
|
|
|
|
|
String masked = maskPhone(request.getPhoneNumber());
|
|
|
|
|
String msgId = "MOCK-MSG-" + UUID.randomUUID();
|
|
|
|
|
log.info("[MOCK MSG] send channel={} to={} title={} refType={} refId={} msgId={}",
|
|
|
|
|
request.getChannel(), masked, request.getTitle(),
|
|
|
|
|
request.getRefType(), request.getRefId(), msgId);
|
|
|
|
|
|
|
|
|
|
return MessageResponse.builder()
|
|
|
|
|
.messageId(msgId)
|
|
|
|
|
.sent(true)
|
|
|
|
|
.resultCode("0000")
|
|
|
|
|
.resultMessage("MOCK sent")
|
|
|
|
|
.sentAt(LocalDateTime.now())
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String maskPhone(String phone) {
|
|
|
|
|
if (phone == null) return null;
|
|
|
|
|
String digits = phone.replaceAll("[^0-9]", "");
|
|
|
|
|
if (digits.length() <= 4) return "****";
|
|
|
|
|
return "***-****-" + digits.substring(digits.length() - 4);
|
|
|
|
|
}
|
|
|
|
|
}
|