260713_01_ENH: 발송 결과에 result code에 대한 label 매칭해서 반환하도록 수정, bulksend에 대한 결과 조회도 통일
This commit is contained in:
@@ -8,7 +8,6 @@ import com.kri.notihub.server.common.enums.ChannelType;
|
||||
import com.kri.notihub.server.common.enums.SendType;
|
||||
import com.kri.notihub.server.dto.report.BulkSendInfoDto;
|
||||
import com.kri.notihub.server.dto.report.ReportExcelResponseDto;
|
||||
import com.kri.notihub.server.dto.report.SendInfoDto;
|
||||
import com.kri.notihub.server.dto.report.SendResultCodeDto;
|
||||
import com.kri.notihub.server.dto.report.SendResultInfoDto;
|
||||
import com.kri.notihub.server.dto.report.SendResultSummaryRequestDto;
|
||||
@@ -67,7 +66,7 @@ public class ReportController {
|
||||
|
||||
@Operation(summary = "대량발송 결과 조회")
|
||||
@PostMapping("/bulk-detail/{bulkSendKey}")
|
||||
public PageResponseDto<SendInfoDto> getBulkSendDetail(
|
||||
public PageResponseDto<SendResultInfoDto> getBulkSendDetail(
|
||||
@PathVariable String bulkSendKey,
|
||||
@Valid @RequestBody PageRequestDto pageReq
|
||||
) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.kri.notihub.server.dto.report;
|
||||
|
||||
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
||||
import com.kri.notihub.server.persistence.entity.TSendResultCodeEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -41,6 +44,14 @@ public class SendResultInfoDto {
|
||||
@Schema(description = "결과 코드")
|
||||
private Short resultCode;
|
||||
|
||||
@Size(max = 128)
|
||||
@Schema(description = "결과 라벨")
|
||||
private String resultLabel;
|
||||
|
||||
@Size(max = 128)
|
||||
@Schema(description = "결과 표시 라벨")
|
||||
private String resultViewLabel;
|
||||
|
||||
@Schema(description = "템플릿 인덱스")
|
||||
private Long tmplatIdx;
|
||||
|
||||
@@ -91,16 +102,25 @@ public class SendResultInfoDto {
|
||||
private LocalDateTime regDt;
|
||||
|
||||
public static SendResultInfoDto from(TSendEntity entity) {
|
||||
return from(entity, null);
|
||||
}
|
||||
|
||||
public static SendResultInfoDto from(TSendEntity entity,
|
||||
List<TSendResultCodeEntity> resultCodeEntity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TSendResultCodeEntity resultCode = findResultCode(entity, resultCodeEntity);
|
||||
|
||||
return SendResultInfoDto.builder()
|
||||
.cmid(entity.getCmid())
|
||||
.bulkSendKey(entity.getBulkSendKey())
|
||||
.sendTy(entity.getSendTy())
|
||||
.resve(entity.isResve())
|
||||
.resultCode(entity.getResultCode())
|
||||
.resultLabel(resultCode != null ? resultCode.getResultLabel() : null)
|
||||
.resultViewLabel(resultCode != null ? resultCode.getResultViewLabel() : null)
|
||||
.tmplatIdx(entity.getTmplatIdx())
|
||||
.kkoTmplatCd(entity.getKkoTmplatCd())
|
||||
.sendEml(entity.getSendEml())
|
||||
@@ -115,4 +135,18 @@ public class SendResultInfoDto {
|
||||
.regDt(entity.getRegDt())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static TSendResultCodeEntity findResultCode(TSendEntity entity,
|
||||
List<TSendResultCodeEntity> resultCodeEntity) {
|
||||
if (resultCodeEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return resultCodeEntity.stream()
|
||||
.filter(e -> e.getId() != null)
|
||||
.filter(e -> Objects.equals(e.getId().getSendCorp(), entity.getSendCorp()))
|
||||
.filter(e -> Objects.equals(e.getId().getResultCode(), entity.getResultCode()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class ReportService {
|
||||
public List<SendResultInfoDto> getSendResultList(String sid, String prjctCd, String reqstSvc,
|
||||
ChannelType channelTy) {
|
||||
List<Short> sendTyList = getSendTypeCodeList(channelTy);
|
||||
List<TSendResultCodeEntity> resultCodeList = sendResultCodeRepository.findAll();
|
||||
|
||||
List<TSendEntity> sendList = sendTyList == null
|
||||
? sendRepository.findBySidAndPrjctCdAndReqstSvcOrderBySendDtDescSendIdxDesc(
|
||||
@@ -72,7 +73,7 @@ public class ReportService {
|
||||
|
||||
return sendList
|
||||
.stream()
|
||||
.map(SendResultInfoDto::from)
|
||||
.map(entity -> SendResultInfoDto.from(entity, resultCodeList))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -91,13 +92,13 @@ public class ReportService {
|
||||
}
|
||||
}
|
||||
|
||||
public PageResponseDto<SendInfoDto> getBulkSendDetail(String bulkSendKey,
|
||||
public PageResponseDto<SendResultInfoDto> getBulkSendDetail(String bulkSendKey,
|
||||
PageRequestDto pageReq) {
|
||||
List<TSendResultCodeEntity> resultCodeList = sendResultCodeRepository.findAll();
|
||||
|
||||
Pageable pageable = Pageables.of(pageReq, TSendEntity.class);
|
||||
Page<SendInfoDto> page = sendRepository.findByBulkSendKey(bulkSendKey, pageable)
|
||||
.map(entity -> SendInfoDto.from(entity, resultCodeList));
|
||||
Page<SendResultInfoDto> page = sendRepository.findByBulkSendKey(bulkSendKey, pageable)
|
||||
.map(entity -> SendResultInfoDto.from(entity, resultCodeList));
|
||||
|
||||
return PageResponseDto.from(page);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user