diff --git a/AGENTS.md b/AGENTS.md index 6e05bfb..3236f71 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -252,6 +252,10 @@ When implementation is complete, report in Korean: - Multipart filenames, including non-ASCII names, are sent unchanged in the quoted `filename` parameter as raw UTF-8. No ASCII fallback or `filename*` parameter is added; CR/LF rejection and quote/backslash escaping still apply. - `JsonUtil` requires the consumer's explicit `ObjectMapper`; shared date/time helpers define KST as `Asia/Seoul` and also expose UTC semantics. +### Project Instruction Budget + +- Keep `.agent/project.md` at or below 9 KiB (9,216 bytes) as the normal target. Do not delete material rules merely to meet the budget; move schema details, query or procedure inventories, API examples, and migration history to linked project documentation, and keep concise read-routing instructions here. + ### Upgrade and Verification - Review KriCommon release notes, README changes, configuration defaults, auto-configuration conditions, and affected public APIs before upgrading. diff --git a/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubApiClient.java b/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubApiClient.java index 697c67d..adcb017 100644 --- a/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubApiClient.java +++ b/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubApiClient.java @@ -41,12 +41,18 @@ public class NotiHubApiClient { } } - public void sendEmailSingle(NotiHubSendRequestSingleDto request, RequestUserContext ctx) { - postSingle("/send-email/single", request, ctx); + public NotiHubSendSingleResponseDto sendEmailSingle( + NotiHubSendRequestSingleDto request, + RequestUserContext ctx + ) { + return postSingle("/send-email/single", request, ctx); } - public void sendSmsSingle(NotiHubSendRequestSingleDto request, RequestUserContext ctx) { - postSingle("/send-sms/single", request, ctx); + public NotiHubSendSingleResponseDto sendSmsSingle( + NotiHubSendRequestSingleDto request, + RequestUserContext ctx + ) { + return postSingle("/send-sms/single", request, ctx); } public String createEmailBulk(NotiHubBulkSendCreateRequestDto request) { @@ -85,8 +91,19 @@ public class NotiHubApiClient { } } - private void postSingle(String path, NotiHubSendRequestSingleDto request, RequestUserContext ctx) { - post(urlWithContext(path, ctx), request); + private NotiHubSendSingleResponseDto postSingle( + String path, + NotiHubSendRequestSingleDto request, + RequestUserContext ctx + ) { + String url = urlWithContext(path, ctx); + try { + ExternalApiResponse response = post(url, request); + return objectMapper.readValue(response.getBody(), NotiHubSendSingleResponseDto.class); + } catch (JsonProcessingException e) { + throw BusinessException.badRequest("NOTI_HUB_RESPONSE_PARSE_FAILED", "noti-hub 응답을 해석할 수 없습니다.") + .with("url", url); + } } private String createBulk(String path, NotiHubBulkSendCreateRequestDto request) { diff --git a/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubSendSingleResponseDto.java b/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubSendSingleResponseDto.java new file mode 100644 index 0000000..f42afa8 --- /dev/null +++ b/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubSendSingleResponseDto.java @@ -0,0 +1,20 @@ +package com.kri.contact.server.common.external.notihub; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Map; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@Schema(description = "NotiHubSendSingleResponseDto") +public class NotiHubSendSingleResponseDto { + + @Schema(description = "cmid") + private String cmid; + + @Schema(description = "data") + private Map data; +} diff --git a/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubTemplateDto.java b/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubTemplateDto.java index 918fc2f..8edd970 100644 --- a/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubTemplateDto.java +++ b/src/main/java/com/kri/contact/server/common/external/notihub/NotiHubTemplateDto.java @@ -16,6 +16,8 @@ public class NotiHubTemplateDto { @Schema(description = "tmplatIdx") private Long tmplatIdx; + @Schema(description = "tmplatPurpose") + private Integer tmplatPurpose; @Schema(description = "tmplatTitle") private String tmplatTitle; @Schema(description = "tmplatBody") diff --git a/src/main/java/com/kri/contact/server/controller/MessageController.java b/src/main/java/com/kri/contact/server/controller/MessageController.java index dd04dda..578f019 100644 --- a/src/main/java/com/kri/contact/server/controller/MessageController.java +++ b/src/main/java/com/kri/contact/server/controller/MessageController.java @@ -4,6 +4,7 @@ import com.kri.common.feature.web.RequestUserContext; import com.kri.contact.server.dto.message.MessageBulkSendResponseDto; import com.kri.contact.server.dto.message.MessageSendBulkRequestDto; import com.kri.contact.server.dto.message.MessageSendSingleRequestDto; +import com.kri.contact.server.dto.message.MessageSendSingleResponseDto; import com.kri.contact.server.service.MessageService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -25,12 +26,12 @@ public class MessageController { @Operation(summary = "Email single send") @PostMapping("/email/single/{prjctIdx}") - public void sendEmailSingle( + public MessageSendSingleResponseDto sendEmailSingle( @PathVariable Long prjctIdx, @Valid @RequestBody MessageSendSingleRequestDto request, RequestUserContext ctx ) { - messageService.sendEmailSingle(prjctIdx, request, ctx); + return messageService.sendEmailSingle(prjctIdx, request, ctx); } @Operation(summary = "Email bulk send") @@ -45,12 +46,12 @@ public class MessageController { @Operation(summary = "SMS single send") @PostMapping("/sms/single/{prjctIdx}") - public void sendSmsSingle( + public MessageSendSingleResponseDto sendSmsSingle( @PathVariable Long prjctIdx, @Valid @RequestBody MessageSendSingleRequestDto request, RequestUserContext ctx ) { - messageService.sendSmsSingle(prjctIdx, request, ctx); + return messageService.sendSmsSingle(prjctIdx, request, ctx); } @Operation(summary = "SMS bulk send") diff --git a/src/main/java/com/kri/contact/server/dto/message/MessageSendSingleResponseDto.java b/src/main/java/com/kri/contact/server/dto/message/MessageSendSingleResponseDto.java new file mode 100644 index 0000000..964a930 --- /dev/null +++ b/src/main/java/com/kri/contact/server/dto/message/MessageSendSingleResponseDto.java @@ -0,0 +1,26 @@ +package com.kri.contact.server.dto.message; + +import com.kri.contact.server.common.external.notihub.NotiHubSendSingleResponseDto; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Map; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +@Schema(description = "Message single send response") +public class MessageSendSingleResponseDto { + + @Schema(description = "cmid") + private String cmid; + + @Schema(description = "data") + private Map data; + + public static MessageSendSingleResponseDto from(NotiHubSendSingleResponseDto response) { + return MessageSendSingleResponseDto.builder() + .cmid(response.getCmid()) + .data(response.getData()) + .build(); + } +} diff --git a/src/main/java/com/kri/contact/server/service/MessageService.java b/src/main/java/com/kri/contact/server/service/MessageService.java index f16520d..b691805 100644 --- a/src/main/java/com/kri/contact/server/service/MessageService.java +++ b/src/main/java/com/kri/contact/server/service/MessageService.java @@ -13,6 +13,7 @@ import com.kri.contact.server.common.external.notihub.NotiHubBulkSendResponseDto import com.kri.contact.server.common.external.notihub.NotiHubDestInfoDto; import com.kri.contact.server.common.external.notihub.NotiHubSendRequestBulkDto; import com.kri.contact.server.common.external.notihub.NotiHubSendRequestSingleDto; +import com.kri.contact.server.common.external.notihub.NotiHubSendSingleResponseDto; import com.kri.contact.server.common.external.notihub.NotiHubTemplateDto; import com.kri.contact.server.dto.list.ListHeaderDto; import com.kri.contact.server.dto.list.ListSendResultDto; @@ -20,6 +21,7 @@ import com.kri.contact.server.dto.message.MessageBulkSendResponseDto; import com.kri.contact.server.dto.message.MessageFailedChunkDto; import com.kri.contact.server.dto.message.MessageSendBulkRequestDto; import com.kri.contact.server.dto.message.MessageSendSingleRequestDto; +import com.kri.contact.server.dto.message.MessageSendSingleResponseDto; import com.kri.contact.server.dto.project.ProjectInfoDto; import java.util.ArrayList; import java.util.Collection; @@ -52,13 +54,21 @@ public class MessageService { private final NotiHubApiClient notiHubApiClient; @Transactional(readOnly = true) - public void sendEmailSingle(Long prjctIdx, MessageSendSingleRequestDto request, RequestUserContext ctx) { - sendSingle(prjctIdx, request, ctx, ChannelType.EMAIL); + public MessageSendSingleResponseDto sendEmailSingle( + Long prjctIdx, + MessageSendSingleRequestDto request, + RequestUserContext ctx + ) { + return sendSingle(prjctIdx, request, ctx, ChannelType.EMAIL); } @Transactional(readOnly = true) - public void sendSmsSingle(Long prjctIdx, MessageSendSingleRequestDto request, RequestUserContext ctx) { - sendSingle(prjctIdx, request, ctx, ChannelType.SMS); + public MessageSendSingleResponseDto sendSmsSingle( + Long prjctIdx, + MessageSendSingleRequestDto request, + RequestUserContext ctx + ) { + return sendSingle(prjctIdx, request, ctx, ChannelType.SMS); } @Transactional(readOnly = true) @@ -71,7 +81,7 @@ public class MessageService { return sendBulk(prjctIdx, request, ctx, ChannelType.SMS); } - private void sendSingle( + private MessageSendSingleResponseDto sendSingle( Long prjctIdx, MessageSendSingleRequestDto request, RequestUserContext ctx, @@ -100,6 +110,7 @@ public class MessageService { throw BusinessException.badRequest("NO_DESTINATION", "발송 대상 이메일 또는 전화번호가 없습니다."); } + NotiHubSendSingleResponseDto response = null; for (NotiHubDestInfoDto destInfo : destInfos) { NotiHubSendRequestSingleDto notiRequest = NotiHubSendRequestSingleDto.builder() .destInfo(destInfo) @@ -111,11 +122,12 @@ public class MessageService { .build(); if (channelType == ChannelType.EMAIL) { - notiHubApiClient.sendEmailSingle(notiRequest, ctx); + response = notiHubApiClient.sendEmailSingle(notiRequest, ctx); } else { - notiHubApiClient.sendSmsSingle(notiRequest, ctx); + response = notiHubApiClient.sendSmsSingle(notiRequest, ctx); } } + return MessageSendSingleResponseDto.from(response); } private MessageBulkSendResponseDto sendBulk(