develop #38
@@ -31,6 +31,8 @@ import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateBasicDt
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDetailDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateSummaryDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendCancelBulkRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendCancelSingleRequestDto;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -74,6 +76,22 @@ public class NotiHubApiClient {
|
||||
@Value("${kri.auth.apikey.key}")
|
||||
private String apiKey;
|
||||
|
||||
public ResponseEntity<byte[]> cancelSingle(
|
||||
MessageSendCancelSingleRequestDto body,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return forward(request, toJsonBytes(body), request.getContentType(), ctx);
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> cancelBulk(
|
||||
MessageSendCancelBulkRequestDto body,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return forward(request, toJsonBytes(body), request.getContentType(), ctx);
|
||||
}
|
||||
|
||||
public NotiHubTemplateDto getTemplate(Long tmplatIdx) {
|
||||
String url = notiHubBaseUrl + "/template/" + tmplatIdx;
|
||||
try {
|
||||
@@ -498,7 +516,8 @@ public class NotiHubApiClient {
|
||||
}
|
||||
|
||||
private String toNotiHubPath(String path) {
|
||||
String notiHubPath = replacePathPrefix(path, "/message-template", "/template");
|
||||
String notiHubPath = replacePathPrefix(path, "/message-send/cancel", "/send/cancel");
|
||||
notiHubPath = replacePathPrefix(notiHubPath, "/message-template", "/template");
|
||||
notiHubPath = replacePathPrefix(notiHubPath, "/message-report", "/report");
|
||||
return replacePathPrefix(notiHubPath, "/report/bulk-detail-excel", "/report/bulk-detail/excel");
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import java.util.Map;
|
||||
@Schema(description = "NotiHubSendSingleResponseDto")
|
||||
public record NotiHubSendSingleResponseDto(
|
||||
|
||||
@Schema(description = "NotiHub send identifier for single cancellation")
|
||||
Long sendIdx,
|
||||
|
||||
@Schema(description = "cmid")
|
||||
String cmid,
|
||||
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.dto.message.MessageSendCancelBulkRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendCancelResponseDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendCancelSingleRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendSingleRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendSingleResponseDto;
|
||||
import com.kri.contact.server.service.MessageSendService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -22,6 +31,30 @@ public class MessageSendController {
|
||||
|
||||
private final MessageSendService messageSendService;
|
||||
|
||||
@Operation(summary = "Cancel a scheduled message")
|
||||
@ApiResponse(responseCode = "200", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
|
||||
schema = @Schema(implementation = MessageSendCancelResponseDto.class)))
|
||||
@PostMapping(value = "/cancel/single", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<byte[]> cancelSingle(
|
||||
@Valid @RequestBody MessageSendCancelSingleRequestDto body,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return messageSendService.cancelSingle(body, request, ctx);
|
||||
}
|
||||
|
||||
@Operation(summary = "Cancel eligible scheduled messages in a bulk send")
|
||||
@ApiResponse(responseCode = "200", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
|
||||
schema = @Schema(implementation = MessageSendCancelResponseDto.class)))
|
||||
@PostMapping(value = "/cancel/bulk", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<byte[]> cancelBulk(
|
||||
@Valid @RequestBody MessageSendCancelBulkRequestDto body,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return messageSendService.cancelBulk(body, request, ctx);
|
||||
}
|
||||
|
||||
@Operation(summary = "Email single send")
|
||||
@PostMapping("/email/single/{prjctIdx}")
|
||||
public MessageSendSingleResponseDto sendEmailSingle(
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.kri.contact.server.dto.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "Bulk scheduled message cancellation request")
|
||||
public record MessageSendCancelBulkRequestDto(
|
||||
@NotBlank @Size(max = 32)
|
||||
@Schema(description = "NotiHub bulk send key", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
String bulkSendKey
|
||||
) {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.kri.contact.server.dto.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "NotiHub cancellation counts; non-cancelable items may be included in a successful response")
|
||||
public record MessageSendCancelResponseDto(
|
||||
long targetCount,
|
||||
long canceledCount,
|
||||
long alreadyCanceledCount,
|
||||
long notCancelableCount
|
||||
) {}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.kri.contact.server.dto.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
|
||||
@Schema(description = "Single scheduled message cancellation request")
|
||||
public record MessageSendCancelSingleRequestDto(
|
||||
@NotNull @Positive
|
||||
@Schema(description = "NotiHub send identifier", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
Long sendIdx
|
||||
) {}
|
||||
@@ -9,6 +9,9 @@ import lombok.Builder;
|
||||
@Schema(description = "Message single send response")
|
||||
public record MessageSendSingleResponseDto(
|
||||
|
||||
@Schema(description = "NotiHub send identifier for single cancellation")
|
||||
Long sendIdx,
|
||||
|
||||
@Schema(description = "cmid")
|
||||
String cmid,
|
||||
|
||||
@@ -18,6 +21,7 @@ public record MessageSendSingleResponseDto(
|
||||
|
||||
public static MessageSendSingleResponseDto from(NotiHubSendSingleResponseDto response) {
|
||||
return MessageSendSingleResponseDto.builder()
|
||||
.sendIdx(response.sendIdx())
|
||||
.cmid(response.cmid())
|
||||
.data(response.data())
|
||||
.build();
|
||||
|
||||
@@ -23,8 +23,11 @@ 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.message.MessageSendCancelBulkRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendCancelSingleRequestDto;
|
||||
import com.kri.contact.server.dto.project.ProjectInfoDto;
|
||||
import com.kri.contact.server.dto.project.ProjectSurveyDto;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -40,6 +43,7 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.SetUtils;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -54,6 +58,22 @@ public class MessageSendService {
|
||||
private final ListSearchService listSearchService;
|
||||
private final NotiHubApiClient notiHubApiClient;
|
||||
|
||||
public ResponseEntity<byte[]> cancelSingle(
|
||||
MessageSendCancelSingleRequestDto body,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return notiHubApiClient.cancelSingle(body, request, ctx);
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> cancelBulk(
|
||||
MessageSendCancelBulkRequestDto body,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return notiHubApiClient.cancelBulk(body, request, ctx);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public MessageSendSingleResponseDto sendEmailSingle(
|
||||
Long prjctIdx,
|
||||
|
||||
@@ -46,6 +46,8 @@ kri:
|
||||
- /message-template
|
||||
- /message-template/**
|
||||
- /message-report/**
|
||||
- /message-send/cancel/single
|
||||
- /message-send/cancel/bulk
|
||||
auth:
|
||||
apikey:
|
||||
key: "4B726963-436F6E74616374-53657276696365-402531213230"
|
||||
|
||||
Reference in New Issue
Block a user