260803_02_ENH: 추후 첨부파일 발송을 위한 프링고 parameter-send로 발송 방식 교체 및 메일 발송 시 <mark> 태그 <span>으로 교체해서 발송되도록 수정
This commit is contained in:
@@ -7,12 +7,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.kri.common.feature.http.ExternalApiClient;
|
import com.kri.common.feature.http.ExternalApiClient;
|
||||||
import com.kri.common.feature.http.ExternalApiMultipartPart;
|
import com.kri.common.feature.http.ExternalApiMultipartPart;
|
||||||
import com.kri.common.feature.http.ExternalApiResponse;
|
import com.kri.common.feature.http.ExternalApiResponse;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonReturnErrorDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoReturnErrorDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonReturnItemDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoReturnItemDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonReturnRequestDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoReturnRequestDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonReturnResponseDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoReturnResponseDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonSendRequestDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoSendRequestDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonSendResponseDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoSendResponseDto;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -41,7 +41,7 @@ public class PringoApiClient {
|
|||||||
/**
|
/**
|
||||||
* Pringo automatic email JSON send POST {pringoBaseUrl}/json-send.
|
* Pringo automatic email JSON send POST {pringoBaseUrl}/json-send.
|
||||||
*/
|
*/
|
||||||
public PringoJsonSendResponseDto jsonSend(PringoJsonSendRequestDto request) {
|
public PringoSendResponseDto jsonSend(PringoSendRequestDto request) {
|
||||||
String url = String.format("%s/json-send", pringoBaseUrl);
|
String url = String.format("%s/json-send", pringoBaseUrl);
|
||||||
|
|
||||||
request.applyDefaults(apiKey, templateId);
|
request.applyDefaults(apiKey, templateId);
|
||||||
@@ -55,7 +55,7 @@ public class PringoApiClient {
|
|||||||
String body = objectMapper.writeValueAsString(request);
|
String body = objectMapper.writeValueAsString(request);
|
||||||
ExternalApiResponse response = externalApiClient.post(url, headers, body);
|
ExternalApiResponse response = externalApiClient.post(url, headers, body);
|
||||||
|
|
||||||
return objectMapper.readValue(response.getBody(), PringoJsonSendResponseDto.class);
|
return objectMapper.readValue(response.getBody(), PringoSendResponseDto.class);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new IllegalStateException("Failed to call Pringo json-send API.", e);
|
throw new IllegalStateException("Failed to call Pringo json-send API.", e);
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ public class PringoApiClient {
|
|||||||
/**
|
/**
|
||||||
* Pringo automatic email parameter send POST {pringoBaseUrl}/parameter-send.
|
* Pringo automatic email parameter send POST {pringoBaseUrl}/parameter-send.
|
||||||
*/
|
*/
|
||||||
public PringoJsonSendResponseDto parameterSend(PringoJsonSendRequestDto request) {
|
public PringoSendResponseDto parameterSend(PringoSendRequestDto request) {
|
||||||
String url = String.format("%s/parameter-send", pringoBaseUrl);
|
String url = String.format("%s/parameter-send", pringoBaseUrl);
|
||||||
|
|
||||||
request.applyDefaults(apiKey, templateId);
|
request.applyDefaults(apiKey, templateId);
|
||||||
@@ -85,13 +85,13 @@ public class PringoApiClient {
|
|||||||
addFormField(parts, "user_info", objectMapper.writeValueAsString(buildUserInfo(request)));
|
addFormField(parts, "user_info", objectMapper.writeValueAsString(buildUserInfo(request)));
|
||||||
|
|
||||||
ExternalApiResponse response = externalApiClient.postMultipart(url, headers, parts);
|
ExternalApiResponse response = externalApiClient.postMultipart(url, headers, parts);
|
||||||
return objectMapper.readValue(response.getBody(), PringoJsonSendResponseDto.class);
|
return objectMapper.readValue(response.getBody(), PringoSendResponseDto.class);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new IllegalStateException("Failed to call Pringo parameter-send API.", e);
|
throw new IllegalStateException("Failed to call Pringo parameter-send API.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PringoJsonSendResponseDto jsonSend(
|
public PringoSendResponseDto jsonSend(
|
||||||
String sender,
|
String sender,
|
||||||
String senderName,
|
String senderName,
|
||||||
String recipient,
|
String recipient,
|
||||||
@@ -100,7 +100,7 @@ public class PringoApiClient {
|
|||||||
String htmlBody,
|
String htmlBody,
|
||||||
Map<String, Object> vars
|
Map<String, Object> vars
|
||||||
) {
|
) {
|
||||||
PringoJsonSendRequestDto req = PringoJsonSendRequestDto.builder()
|
PringoSendRequestDto req = PringoSendRequestDto.builder()
|
||||||
.sender(sender)
|
.sender(sender)
|
||||||
.senderName(senderName)
|
.senderName(senderName)
|
||||||
.recipient(recipient)
|
.recipient(recipient)
|
||||||
@@ -119,7 +119,7 @@ public class PringoApiClient {
|
|||||||
/**
|
/**
|
||||||
* Pringo automatic email JSON return POST {pringoBaseUrl}/json-return.
|
* Pringo automatic email JSON return POST {pringoBaseUrl}/json-return.
|
||||||
*/
|
*/
|
||||||
public PringoJsonReturnResponseDto jsonReturn(PringoJsonReturnRequestDto request) {
|
public PringoReturnResponseDto jsonReturn(PringoReturnRequestDto request) {
|
||||||
String url = String.format("%s/json-return", pringoBaseUrl);
|
String url = String.format("%s/json-return", pringoBaseUrl);
|
||||||
|
|
||||||
request.applyDefaults(apiKey, templateId);
|
request.applyDefaults(apiKey, templateId);
|
||||||
@@ -135,7 +135,7 @@ public class PringoApiClient {
|
|||||||
|
|
||||||
JsonNode root = objectMapper.readTree(response.getBody());
|
JsonNode root = objectMapper.readTree(response.getBody());
|
||||||
if (root == null || !root.isArray() || root.size() == 0) {
|
if (root == null || !root.isArray() || root.size() == 0) {
|
||||||
return PringoJsonReturnResponseDto.builder()
|
return PringoReturnResponseDto.builder()
|
||||||
.itemList(List.of())
|
.itemList(List.of())
|
||||||
.error(PringoJsonReturnErrorDtoBuilder.noResultFallback())
|
.error(PringoJsonReturnErrorDtoBuilder.noResultFallback())
|
||||||
.build();
|
.build();
|
||||||
@@ -144,20 +144,20 @@ public class PringoApiClient {
|
|||||||
JsonNode first = root.get(0);
|
JsonNode first = root.get(0);
|
||||||
|
|
||||||
if (first.has("result") && first.has("msg")) {
|
if (first.has("result") && first.has("msg")) {
|
||||||
PringoJsonReturnErrorDto err = objectMapper.convertValue(first,
|
PringoReturnErrorDto err = objectMapper.convertValue(first,
|
||||||
PringoJsonReturnErrorDto.class);
|
PringoReturnErrorDto.class);
|
||||||
return PringoJsonReturnResponseDto.builder()
|
return PringoReturnResponseDto.builder()
|
||||||
.itemList(List.of())
|
.itemList(List.of())
|
||||||
.error(err)
|
.error(err)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PringoJsonReturnItemDto> items = objectMapper.convertValue(
|
List<PringoReturnItemDto> items = objectMapper.convertValue(
|
||||||
root, new TypeReference<List<PringoJsonReturnItemDto>>() {
|
root, new TypeReference<List<PringoReturnItemDto>>() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return PringoJsonReturnResponseDto.builder()
|
return PringoReturnResponseDto.builder()
|
||||||
.itemList(items)
|
.itemList(items)
|
||||||
.error(null)
|
.error(null)
|
||||||
.build();
|
.build();
|
||||||
@@ -167,14 +167,14 @@ public class PringoApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PringoJsonReturnResponseDto jsonReturn(String returnKey) {
|
public PringoReturnResponseDto jsonReturn(String returnKey) {
|
||||||
PringoJsonReturnRequestDto req = PringoJsonReturnRequestDto.builder()
|
PringoReturnRequestDto req = PringoReturnRequestDto.builder()
|
||||||
.returnKey(returnKey)
|
.returnKey(returnKey)
|
||||||
.build();
|
.build();
|
||||||
return jsonReturn(req);
|
return jsonReturn(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PringoJsonReturnResponseDto jsonReturn(long returnKey) {
|
public PringoReturnResponseDto jsonReturn(long returnKey) {
|
||||||
return jsonReturn(Long.toString(returnKey));
|
return jsonReturn(Long.toString(returnKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public class PringoApiClient {
|
|||||||
parts.add(ExternalApiMultipartPart.formField(name, value));
|
parts.add(ExternalApiMultipartPart.formField(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> buildUserInfo(PringoJsonSendRequestDto request) {
|
private Map<String, Object> buildUserInfo(PringoSendRequestDto request) {
|
||||||
Map<String, Object> recipientInfo = new LinkedHashMap<>();
|
Map<String, Object> recipientInfo = new LinkedHashMap<>();
|
||||||
recipientInfo.put("alternates", request.getVars() == null ? Map.of() : request.getVars());
|
recipientInfo.put("alternates", request.getVars() == null ? Map.of() : request.getVars());
|
||||||
|
|
||||||
@@ -196,10 +196,10 @@ public class PringoApiClient {
|
|||||||
|
|
||||||
private static final class PringoJsonReturnErrorDtoBuilder {
|
private static final class PringoJsonReturnErrorDtoBuilder {
|
||||||
|
|
||||||
static PringoJsonReturnErrorDto noResultFallback() {
|
static PringoReturnErrorDto noResultFallback() {
|
||||||
PringoJsonReturnErrorDto e = new PringoJsonReturnErrorDto();
|
PringoReturnErrorDto e = new PringoReturnErrorDto();
|
||||||
e.setResult("0");
|
e.setResult("0");
|
||||||
e.setMsg("\uC751\uB2F5\uC774 \uBE44\uC5B4 \uC788\uC2B5\uB2C8\uB2E4.");
|
e.setMsg("응답이 비어 있습니다.");
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class PringoJsonReturnErrorDto {
|
public class PringoReturnErrorDto {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class PringoJsonReturnItemDto {
|
public class PringoReturnItemDto {
|
||||||
|
|
||||||
@JsonProperty("No")
|
@JsonProperty("No")
|
||||||
private Integer no;
|
private Integer no;
|
||||||
@@ -13,7 +13,7 @@ import lombok.Setter;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PringoJsonReturnRequestDto {
|
public class PringoReturnRequestDto {
|
||||||
|
|
||||||
@JsonProperty("api_key")
|
@JsonProperty("api_key")
|
||||||
private String apiKey;
|
private String apiKey;
|
||||||
@@ -12,17 +12,17 @@ import lombok.Setter;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PringoJsonReturnResponseDto {
|
public class PringoReturnResponseDto {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 조회 결과 row들(성공 시)
|
* 조회 결과 row들(성공 시)
|
||||||
*/
|
*/
|
||||||
private List<PringoJsonReturnItemDto> itemList;
|
private List<PringoReturnItemDto> itemList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 조회 실패/없음(실패 시)
|
* 조회 실패/없음(실패 시)
|
||||||
*/
|
*/
|
||||||
private PringoJsonReturnErrorDto error;
|
private PringoReturnErrorDto error;
|
||||||
|
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
return itemList != null && !itemList.isEmpty();
|
return itemList != null && !itemList.isEmpty();
|
||||||
@@ -20,7 +20,7 @@ import lombok.Setter;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PringoJsonSendRequestDto {
|
public class PringoSendRequestDto {
|
||||||
|
|
||||||
private static final Set<String> RESERVED_KEYS = Set.of(
|
private static final Set<String> RESERVED_KEYS = Set.of(
|
||||||
"api_key", "template_id",
|
"api_key", "template_id",
|
||||||
@@ -71,19 +71,19 @@ public class PringoJsonSendRequestDto {
|
|||||||
/**
|
/**
|
||||||
* TemplateBasicDto -> Pringo 발송 DTO 기본 매핑 - recipient/recipientName 은 템플릿에 없으므로 여기서는 비워두고 이후 세팅
|
* TemplateBasicDto -> Pringo 발송 DTO 기본 매핑 - recipient/recipientName 은 템플릿에 없으므로 여기서는 비워두고 이후 세팅
|
||||||
*/
|
*/
|
||||||
public static PringoJsonSendRequestDto from(TemplateBasicDto template, String sendName,
|
public static PringoSendRequestDto from(TemplateBasicDto template, String sendName,
|
||||||
String sendEmail) {
|
String sendEmail) {
|
||||||
return from(template, sendName, sendEmail, null, null);
|
return from(template, sendName, sendEmail, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PringoJsonSendRequestDto from(TemplateBasicDto template, String sendName,
|
public static PringoSendRequestDto from(TemplateBasicDto template, String sendName,
|
||||||
String sendEmail, String recipient, String recipientName) {
|
String sendEmail, String recipient, String recipientName) {
|
||||||
Objects.requireNonNull(template, "template is required");
|
Objects.requireNonNull(template, "template is required");
|
||||||
|
|
||||||
String sender = sendEmail != null && !sendEmail.isBlank() ? sendEmail : template.getSendEml();
|
String sender = sendEmail != null && !sendEmail.isBlank() ? sendEmail : template.getSendEml();
|
||||||
String senderName = sendName != null && !sendName.isBlank() ? sendName : template.getSendNm();
|
String senderName = sendName != null && !sendName.isBlank() ? sendName : template.getSendNm();
|
||||||
|
|
||||||
return PringoJsonSendRequestDto.builder()
|
return PringoSendRequestDto.builder()
|
||||||
.sender(sender)
|
.sender(sender)
|
||||||
.senderName(senderName)
|
.senderName(senderName)
|
||||||
.recipient(recipient)
|
.recipient(recipient)
|
||||||
@@ -93,7 +93,7 @@ public class PringoJsonSendRequestDto {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PringoJsonSendRequestDto of(
|
public static PringoSendRequestDto of(
|
||||||
String sender,
|
String sender,
|
||||||
String senderName,
|
String senderName,
|
||||||
String recipient,
|
String recipient,
|
||||||
@@ -101,7 +101,7 @@ public class PringoJsonSendRequestDto {
|
|||||||
String subject,
|
String subject,
|
||||||
String htmlBody
|
String htmlBody
|
||||||
) {
|
) {
|
||||||
return PringoJsonSendRequestDto.builder()
|
return PringoSendRequestDto.builder()
|
||||||
.sender(sender)
|
.sender(sender)
|
||||||
.senderName(senderName)
|
.senderName(senderName)
|
||||||
.recipient(recipient)
|
.recipient(recipient)
|
||||||
@@ -132,8 +132,8 @@ public class PringoJsonSendRequestDto {
|
|||||||
setAny(key, value);
|
setAny(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PringoJsonSendRequestDto copy() {
|
public PringoSendRequestDto copy() {
|
||||||
return PringoJsonSendRequestDto.builder()
|
return PringoSendRequestDto.builder()
|
||||||
.apiKey(this.apiKey)
|
.apiKey(this.apiKey)
|
||||||
.templateId(this.templateId)
|
.templateId(this.templateId)
|
||||||
.sender(this.sender)
|
.sender(this.sender)
|
||||||
@@ -149,7 +149,7 @@ public class PringoJsonSendRequestDto {
|
|||||||
/**
|
/**
|
||||||
* recipient를 나중에 세팅할 수 있게 체이닝용
|
* recipient를 나중에 세팅할 수 있게 체이닝용
|
||||||
*/
|
*/
|
||||||
public PringoJsonSendRequestDto withRecipient(String recipient, String recipientName) {
|
public PringoSendRequestDto withRecipient(String recipient, String recipientName) {
|
||||||
this.recipient = recipient;
|
this.recipient = recipient;
|
||||||
this.recipientName = recipientName;
|
this.recipientName = recipientName;
|
||||||
return this;
|
return this;
|
||||||
@@ -7,7 +7,7 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class PringoJsonSendResponseDto {
|
public class PringoSendResponseDto {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ import com.kri.common.feature.datetime.DateTimeUtil;
|
|||||||
import com.kri.notihub.server.common.consts.NotihubConst;
|
import com.kri.notihub.server.common.consts.NotihubConst;
|
||||||
import com.kri.notihub.server.common.enums.SendStatusType;
|
import com.kri.notihub.server.common.enums.SendStatusType;
|
||||||
import com.kri.notihub.server.common.enums.SendType;
|
import com.kri.notihub.server.common.enums.SendType;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonSendRequestDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoSendRequestDto;
|
||||||
import com.kri.notihub.server.dto.send.DestInfoDto;
|
import com.kri.notihub.server.dto.send.DestInfoDto;
|
||||||
import com.kri.notihub.server.dto.send.SendInternalResultDto;
|
import com.kri.notihub.server.dto.send.SendInternalResultDto;
|
||||||
import com.kri.notihub.server.persistence.entity.TBulkSendEntity;
|
import com.kri.notihub.server.persistence.entity.TBulkSendEntity;
|
||||||
@@ -123,7 +123,7 @@ public class EmailBulkSendScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendInternalResultDto sendEmail(TSendEntity send) {
|
private SendInternalResultDto sendEmail(TSendEntity send) {
|
||||||
PringoJsonSendRequestDto pringoReq = sendEmailService.buildPringoSendRequest(
|
PringoSendRequestDto pringoReq = sendEmailService.buildPringoSendRequest(
|
||||||
send.getSendEml(),
|
send.getSendEml(),
|
||||||
send.getSendNm(),
|
send.getSendNm(),
|
||||||
send.getMsgTitle(),
|
send.getMsgTitle(),
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ package com.kri.notihub.server.scheduler;
|
|||||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||||
import com.kri.notihub.server.common.consts.NotihubConst;
|
import com.kri.notihub.server.common.consts.NotihubConst;
|
||||||
import com.kri.notihub.server.common.enums.SendType;
|
import com.kri.notihub.server.common.enums.SendType;
|
||||||
import com.kri.notihub.server.common.external.pringo.PringoApiClient;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoSendRequestDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonSendRequestDto;
|
|
||||||
import com.kri.notihub.server.dto.send.DestInfoDto;
|
import com.kri.notihub.server.dto.send.DestInfoDto;
|
||||||
import com.kri.notihub.server.dto.send.SendInternalResultDto;
|
import com.kri.notihub.server.dto.send.SendInternalResultDto;
|
||||||
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
||||||
import com.kri.notihub.server.persistence.jdbc.SendBulkJdbcWriter;
|
|
||||||
import com.kri.notihub.server.persistence.repository.SendRepository;
|
import com.kri.notihub.server.persistence.repository.SendRepository;
|
||||||
import com.kri.notihub.server.service.SendEmailService;
|
import com.kri.notihub.server.service.SendEmailService;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -47,7 +45,7 @@ public class SendReservationEmailScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (TSendEntity s : reservationList) {
|
for (TSendEntity s : reservationList) {
|
||||||
PringoJsonSendRequestDto pringoReq = sendEmlService.buildPringoSendRequest(
|
PringoSendRequestDto pringoReq = sendEmlService.buildPringoSendRequest(
|
||||||
s.getSendEml(),
|
s.getSendEml(),
|
||||||
s.getSendNm(),
|
s.getSendNm(),
|
||||||
s.getMsgTitle(),
|
s.getMsgTitle(),
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import com.kri.notihub.server.common.enums.ChannelType;
|
|||||||
import com.kri.notihub.server.common.enums.SendStatusType;
|
import com.kri.notihub.server.common.enums.SendStatusType;
|
||||||
import com.kri.notihub.server.common.enums.SendType;
|
import com.kri.notihub.server.common.enums.SendType;
|
||||||
import com.kri.notihub.server.common.external.pringo.PringoApiClient;
|
import com.kri.notihub.server.common.external.pringo.PringoApiClient;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonSendRequestDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoSendRequestDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonSendResponseDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoSendResponseDto;
|
||||||
import com.kri.notihub.server.dto.send.DestInfoDto;
|
import com.kri.notihub.server.dto.send.DestInfoDto;
|
||||||
import com.kri.notihub.server.dto.send.SendInternalResultDto;
|
import com.kri.notihub.server.dto.send.SendInternalResultDto;
|
||||||
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
||||||
@@ -84,7 +84,7 @@ public abstract class AbstractPringoSendService extends AbstractSendService {
|
|||||||
|
|
||||||
return SendInternalResultDto.of(cmid, SendStatusType.STANDBY, NotihubConst.EMAIL_STANDBY);
|
return SendInternalResultDto.of(cmid, SendStatusType.STANDBY, NotihubConst.EMAIL_STANDBY);
|
||||||
} else {
|
} else {
|
||||||
PringoJsonSendRequestDto pringoReq = buildPringoSendRequest(
|
PringoSendRequestDto pringoReq = buildPringoSendRequest(
|
||||||
sendEml,
|
sendEml,
|
||||||
sendNm,
|
sendNm,
|
||||||
msgTitle,
|
msgTitle,
|
||||||
@@ -95,13 +95,14 @@ public abstract class AbstractPringoSendService extends AbstractSendService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendInternalResultDto sendPringoEmail(PringoJsonSendRequestDto pringoReq) {
|
public SendInternalResultDto sendPringoEmail(PringoSendRequestDto pringoReq) {
|
||||||
PringoJsonSendResponseDto pringoRes = null;
|
PringoSendResponseDto pringoRes = null;
|
||||||
try {
|
try {
|
||||||
if(StringUtil.isNullOrBlank(pringoReq.getRecipientName())){
|
if(StringUtil.isNullOrBlank(pringoReq.getRecipientName())){
|
||||||
pringoReq.setRecipientName(pringoReq.getRecipient());
|
pringoReq.setRecipientName(pringoReq.getRecipient());
|
||||||
}
|
}
|
||||||
pringoRes = pringoApiClient.jsonSend(pringoReq);
|
// pringoRes = pringoApiClient.jsonSend(pringoReq);
|
||||||
|
pringoRes = pringoApiClient.parameterSend(pringoReq);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Pringo json-send failed (pringoReq={})", pringoReq, e);
|
log.warn("Pringo json-send failed (pringoReq={})", pringoReq, e);
|
||||||
}
|
}
|
||||||
@@ -135,7 +136,7 @@ public abstract class AbstractPringoSendService extends AbstractSendService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PringoJsonSendRequestDto buildPringoSendRequest(
|
public PringoSendRequestDto buildPringoSendRequest(
|
||||||
String sendEml,
|
String sendEml,
|
||||||
String sendNm,
|
String sendNm,
|
||||||
String msgTitle,
|
String msgTitle,
|
||||||
@@ -147,7 +148,7 @@ public abstract class AbstractPringoSendService extends AbstractSendService {
|
|||||||
vars.putAll(dest.getMsgParam());
|
vars.putAll(dest.getMsgParam());
|
||||||
}
|
}
|
||||||
|
|
||||||
return PringoJsonSendRequestDto.builder()
|
return PringoSendRequestDto.builder()
|
||||||
.sender(sendEml)
|
.sender(sendEml)
|
||||||
.senderName(Optional.ofNullable(sendNm).orElse(""))
|
.senderName(Optional.ofNullable(sendNm).orElse(""))
|
||||||
.recipient(dest.getDestEml())
|
.recipient(dest.getDestEml())
|
||||||
@@ -158,7 +159,7 @@ public abstract class AbstractPringoSendService extends AbstractSendService {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveEmailCmid(PringoJsonSendResponseDto pringoRes) {
|
private String resolveEmailCmid(PringoSendResponseDto pringoRes) {
|
||||||
if (pringoRes != null && pringoRes.isSuccess() && pringoRes.getReturnKey() != null) {
|
if (pringoRes != null && pringoRes.isSuccess() && pringoRes.getReturnKey() != null) {
|
||||||
return String.valueOf(pringoRes.getReturnKey());
|
return String.valueOf(pringoRes.getReturnKey());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,23 @@ public class EmailBodyRenderer {
|
|||||||
public String render(String html, Map<String, String> msgParam) {
|
public String render(String html, Map<String, String> msgParam) {
|
||||||
String preparedHtml = replaceQrcodeTagsWithImages(html);
|
String preparedHtml = replaceQrcodeTagsWithImages(html);
|
||||||
String replacedHtml = replacePlaceholder(preparedHtml, msgParam);
|
String replacedHtml = replacePlaceholder(preparedHtml, msgParam);
|
||||||
return replaceQrcodeImagesWithApiUrls(replacedHtml);
|
String qrRenderedHtml = replaceQrcodeImagesWithApiUrls(replacedHtml);
|
||||||
|
return replaceMarkTagsWithSpans(qrRenderedHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String replaceMarkTagsWithSpans(String html) {
|
||||||
|
if (html == null || html.isEmpty()) {
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
Document doc = Jsoup.parseBodyFragment(html);
|
||||||
|
doc.outputSettings(new Document.OutputSettings().prettyPrint(false));
|
||||||
|
|
||||||
|
for (Element mark : doc.select("mark")) {
|
||||||
|
mark.tagName("span");
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc.body().html();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String replaceQrcodeTagsWithImages(String html) {
|
private String replaceQrcodeTagsWithImages(String html) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.kri.common.feature.util.NumericUtil;
|
|||||||
import com.kri.notihub.server.common.consts.NotihubConst;
|
import com.kri.notihub.server.common.consts.NotihubConst;
|
||||||
import com.kri.notihub.server.common.enums.SendStatusType;
|
import com.kri.notihub.server.common.enums.SendStatusType;
|
||||||
import com.kri.notihub.server.common.external.pringo.PringoApiClient;
|
import com.kri.notihub.server.common.external.pringo.PringoApiClient;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonReturnItemDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoReturnItemDto;
|
||||||
import com.kri.notihub.server.common.external.pringo.dto.PringoJsonReturnResponseDto;
|
import com.kri.notihub.server.common.external.pringo.dto.PringoReturnResponseDto;
|
||||||
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
||||||
import com.kri.notihub.server.persistence.repository.BulkSendRepository;
|
import com.kri.notihub.server.persistence.repository.BulkSendRepository;
|
||||||
import com.kri.notihub.server.persistence.repository.SendRepository;
|
import com.kri.notihub.server.persistence.repository.SendRepository;
|
||||||
@@ -39,7 +39,7 @@ class EmailResultUpdater {
|
|||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
TSendEntity e = opt.get();
|
TSendEntity e = opt.get();
|
||||||
try {
|
try {
|
||||||
PringoJsonReturnResponseDto resp = pringoApiClient.jsonReturn(Long.valueOf(returnKey));
|
PringoReturnResponseDto resp = pringoApiClient.jsonReturn(Long.valueOf(returnKey));
|
||||||
if (resp == null || !resp.isSuccess() || resp.getItemList() == null || resp.getItemList()
|
if (resp == null || !resp.isSuccess() || resp.getItemList() == null || resp.getItemList()
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
e.setResultCode(NotihubConst.EMAIL_NOT_RESULT);
|
e.setResultCode(NotihubConst.EMAIL_NOT_RESULT);
|
||||||
@@ -48,7 +48,7 @@ class EmailResultUpdater {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PringoJsonReturnItemDto item = resp.getItemList().get(0);
|
PringoReturnItemDto item = resp.getItemList().get(0);
|
||||||
if (item == null || item.getStatus() == null || item.getStatus().isBlank()) {
|
if (item == null || item.getStatus() == null || item.getStatus().isBlank()) {
|
||||||
e.setResultCode(NotihubConst.EMAIL_NOT_RESULT);
|
e.setResultCode(NotihubConst.EMAIL_NOT_RESULT);
|
||||||
e.setReportDt(now);
|
e.setReportDt(now);
|
||||||
|
|||||||
Reference in New Issue
Block a user