260710_01_ENH: SID 별 발송 결과 조회 구현, 발송 결과 코드 표 조회 구현
This commit is contained in:
@@ -4,10 +4,13 @@ import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.common.feature.web.page.PageRequestDto;
|
||||
import com.kri.common.feature.web.page.PageResponseDto;
|
||||
import com.kri.notihub.server.common.consts.NotihubConst;
|
||||
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;
|
||||
import com.kri.notihub.server.dto.report.SendResultSummaryResponseDto;
|
||||
import com.kri.notihub.server.service.ReportService;
|
||||
@@ -21,6 +24,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@@ -31,6 +35,23 @@ public class ReportController {
|
||||
|
||||
private final ReportService reportService;
|
||||
|
||||
@Operation(summary = "발송 결과 코드 목록 조회")
|
||||
@GetMapping("/send-result-code")
|
||||
public List<SendResultCodeDto> getSendResultCodeList() {
|
||||
return reportService.getSendResultCodeList();
|
||||
}
|
||||
|
||||
@Operation(summary = "발송 결과 목록 조회")
|
||||
@GetMapping("/send-result/{sid}/{prjctCd}/{reqstSvc}")
|
||||
public List<SendResultInfoDto> getSendResultList(
|
||||
@PathVariable String sid,
|
||||
@PathVariable String prjctCd,
|
||||
@PathVariable String reqstSvc,
|
||||
@RequestParam(required = false) ChannelType channelTy
|
||||
) {
|
||||
return reportService.getSendResultList(sid, prjctCd, reqstSvc, channelTy);
|
||||
}
|
||||
|
||||
@Operation(summary = "대량발송 리스트 조회")
|
||||
@GetMapping("/bulk-list/{sendTy}/{reqstSvc}/{prjctCd}")
|
||||
public List<BulkSendInfoDto> getBulkSendList(
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.kri.notihub.server.dto.report;
|
||||
|
||||
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 lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "발송 결과 코드")
|
||||
public class SendResultCodeDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "결과 코드")
|
||||
private Short resultCode;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "결과 타입")
|
||||
private Short resultTy;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "결과 라벨")
|
||||
private String resultLabel;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "결과 표시 라벨")
|
||||
private String resultViewLabel;
|
||||
|
||||
public static SendResultCodeDto from(TSendResultCodeEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SendResultCodeDto.builder()
|
||||
.resultCode(entity.getResultCode())
|
||||
.resultTy(entity.getResultTy())
|
||||
.resultLabel(entity.getResultLabel())
|
||||
.resultViewLabel(entity.getResultViewLabel())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.kri.notihub.server.dto.report;
|
||||
|
||||
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
||||
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 lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "발송 결과 정보")
|
||||
public class SendResultInfoDto {
|
||||
|
||||
@Size(max = 32)
|
||||
@NotBlank
|
||||
@Schema(description = "CMID")
|
||||
private String cmid;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "대량 발송 키")
|
||||
private String bulkSendKey;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "발송 타입")
|
||||
private Short sendTy;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "예약 여부")
|
||||
private Boolean resve;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "결과 코드")
|
||||
private Short resultCode;
|
||||
|
||||
@Schema(description = "템플릿 인덱스")
|
||||
private Long tmplatIdx;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "카카오 템플릿 코드")
|
||||
private String kkoTmplatCd;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "발신 이메일")
|
||||
private String sendEml;
|
||||
|
||||
@Size(max = 16)
|
||||
@Schema(description = "발신 전화번호")
|
||||
private String sendTel;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "발신자명")
|
||||
private String sendNm;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "발송 일시")
|
||||
private LocalDateTime sendDt;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "수신 이메일")
|
||||
private String destEml;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "수신자명")
|
||||
private String destNm;
|
||||
|
||||
@Size(max = 16)
|
||||
@Schema(description = "수신 전화번호")
|
||||
private String destTel;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotBlank
|
||||
@Schema(description = "등록 회사")
|
||||
private String regCmpn;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotBlank
|
||||
@Schema(description = "등록자")
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "등록 일시")
|
||||
private LocalDateTime regDt;
|
||||
|
||||
public static SendResultInfoDto from(TSendEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SendResultInfoDto.builder()
|
||||
.cmid(entity.getCmid())
|
||||
.bulkSendKey(entity.getBulkSendKey())
|
||||
.sendTy(entity.getSendTy())
|
||||
.resve(entity.isResve())
|
||||
.resultCode(entity.getResultCode())
|
||||
.tmplatIdx(entity.getTmplatIdx())
|
||||
.kkoTmplatCd(entity.getKkoTmplatCd())
|
||||
.sendEml(entity.getSendEml())
|
||||
.sendTel(entity.getSendTel())
|
||||
.sendNm(entity.getSendNm())
|
||||
.sendDt(entity.getSendDt())
|
||||
.destEml(entity.getDestEml())
|
||||
.destNm(entity.getDestNm())
|
||||
.destTel(entity.getDestTel())
|
||||
.regCmpn(entity.getRegCmpn())
|
||||
.regUser(entity.getRegUser())
|
||||
.regDt(entity.getRegDt())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.kri.notihub.server.persistence.repository;
|
||||
|
||||
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
||||
import com.kri.notihub.server.dto.report.SendResultSummaryDto;
|
||||
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -67,6 +67,19 @@ public interface SendRepository extends JpaRepository<TSendEntity, Long> {
|
||||
|
||||
Page<TSendEntity> findByBulkSendKey(String bulkSendKey, Pageable pageable);
|
||||
|
||||
List<TSendEntity> findBySidAndPrjctCdAndReqstSvcOrderBySendDtDescSendIdxDesc(
|
||||
String sid,
|
||||
String prjctCd,
|
||||
String reqstSvc
|
||||
);
|
||||
|
||||
List<TSendEntity> findBySidAndPrjctCdAndReqstSvcAndSendTyInOrderBySendDtDescSendIdxDesc(
|
||||
String sid,
|
||||
String prjctCd,
|
||||
String reqstSvc,
|
||||
List<Short> sendTyList
|
||||
);
|
||||
|
||||
@Query("""
|
||||
select new com.kri.notihub.server.dto.report.SendResultSummaryDto(
|
||||
s.sendTy,
|
||||
|
||||
@@ -6,10 +6,13 @@ import com.kri.common.feature.web.page.PageRequestDto;
|
||||
import com.kri.common.feature.web.page.PageResponseDto;
|
||||
import com.kri.common.feature.web.page.Pageables;
|
||||
import com.kri.notihub.server.common.consts.NotihubConst;
|
||||
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.SendResultSummaryDto;
|
||||
import com.kri.notihub.server.dto.report.SendResultSummaryRequestDto;
|
||||
import com.kri.notihub.server.dto.report.SendResultSummaryResponseDto;
|
||||
@@ -51,6 +54,28 @@ public class ReportService {
|
||||
private final SendRepository sendRepository;
|
||||
private final UnitPriceRepository unitPriceRepository;
|
||||
|
||||
public List<SendResultCodeDto> getSendResultCodeList() {
|
||||
return sendResultCodeRepository.findAll().stream()
|
||||
.map(SendResultCodeDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<SendResultInfoDto> getSendResultList(String sid, String prjctCd, String reqstSvc,
|
||||
ChannelType channelTy) {
|
||||
List<Short> sendTyList = getSendTypeCodeList(channelTy);
|
||||
|
||||
List<TSendEntity> sendList = sendTyList == null
|
||||
? sendRepository.findBySidAndPrjctCdAndReqstSvcOrderBySendDtDescSendIdxDesc(
|
||||
sid, prjctCd, reqstSvc)
|
||||
: sendRepository.findBySidAndPrjctCdAndReqstSvcAndSendTyInOrderBySendDtDescSendIdxDesc(
|
||||
sid, prjctCd, reqstSvc, sendTyList);
|
||||
|
||||
return sendList
|
||||
.stream()
|
||||
.map(SendResultInfoDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<BulkSendInfoDto> getBulkSendList(SendType sendTy, String reqstSvc, String prjctCd,
|
||||
String regCmpn) {
|
||||
List<Short> sendTyList = sendTy == SendType.EMAIL ? List.of(SendType.EMAIL.getCode())
|
||||
@@ -221,6 +246,18 @@ public class ReportService {
|
||||
return value != null ? value : 0L;
|
||||
}
|
||||
|
||||
private List<Short> getSendTypeCodeList(ChannelType channelTy) {
|
||||
if (channelTy == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return switch (channelTy) {
|
||||
case EMAIL -> NotihubConst.EMAIL_TYPE_CODE_LIST;
|
||||
case SMS -> NotihubConst.SMS_TYPE_CODE_LIST;
|
||||
case KKO_AT -> NotihubConst.KKO_TYPE_CODE_LIST;
|
||||
};
|
||||
}
|
||||
|
||||
private record SendPriceKey(Short sendTy, Short sendCorp) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user