feat: 표준연계지침 버전변경에 관한 수정(v1.2.1 -> v1.?.?)

1. reqVo 타입변경(Map -> List<Map>)
2. respVo 성공/실패 코드 정의( 000: 성공, 002: 내부오류 )
3. Error 테이블 추가 ( 처리오류 건에 대한 저장 )
dev
minkyu1128 2 years ago
parent d779b92f4d
commit 15f952b32c

@ -10,12 +10,14 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public enum LinkRstCd implements CodeMapperType {
ok("정상")
,fail("실패");
ok("정상", "000")
, internalFail("내부오류", "002");
@Getter
private final String codeNm;
@Getter
private final String extCode;
@Override
public String getCode() {

@ -0,0 +1,45 @@
package cokr.xit.ntri.api.recv.entity;
import cokr.xit.ntri.support.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
@Getter
@ToString
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(schema = "", name = "ntri_recv_error")
@Schema(name = "RecvError", title = "수신오류(실시간)", description = "세외수입시스템으로 수신한 데이터 중 DB저장에 실패한 데이터")
public class RecvError extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
@Schema(required = false, title = "자치단체코드", example = " ", description = "행정표준코드관리시스템의 자치단체코드")
@Column(name = "sgb_cd", length = 255, nullable = true)
private String sgbCd;
@Schema(required = false, title = "연계관리키", example = " ", description = "연계대상 기관에서 관리하는 유일키")
@Column(name = "link_mng_key", length = 255, nullable = true)
private String linkMngKey;
@Schema(required = false, title = "요청데이터", example = " ", description = "세외수입에서 전송한 데이터")
@Lob
@Column(name = "req_data")
private String reqData;
@Schema(required = false, title = "에러메시지", example = " ", description = "에러메시지")
@Column(name = "err_msg", length = 255, nullable = true)
private String errMsg;
@Schema(required = false, title = "에러메시지 상세", example = " ", description = "Runtime Error 메시지")
@Lob
@Column(name = "err_detail", nullable = true)
private String errDetail;
}

@ -0,0 +1,7 @@
package cokr.xit.ntri.api.recv.entity.repository;
import cokr.xit.ntri.api.recv.entity.RecvError;
import org.springframework.data.jpa.repository.JpaRepository;
public interface RecvErrorRepository extends JpaRepository<RecvError, Long> {
}

@ -1,6 +1,5 @@
package cokr.xit.ntri.api.recv.model;
import cokr.xit.ntri.api.recv.code.LinkRstCd;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
@ -19,7 +18,7 @@ public class RecvResponseDTO {
private String linkMngKey;
@Schema(required = false, title = "연계결과코드", example = " ", description = " ")
private LinkRstCd linkRstCd;
private String linkRstCd;
@Schema(required = false, title = "연계결과메시지", example = " ", description = " ")
private String linkRstMsg;

@ -1,9 +1,6 @@
package cokr.xit.ntri.api.recv.presentation;
import cokr.xit.ntri.api.recv.entity.repository.RecvLevyCancelRepository;
import cokr.xit.ntri.api.recv.entity.repository.RecvLevyResultRepository;
import cokr.xit.ntri.api.recv.entity.repository.RecvRcivInfoRepository;
import cokr.xit.ntri.api.recv.entity.repository.RecvRdcamtInfoRepository;
import cokr.xit.ntri.api.recv.entity.repository.*;
import cokr.xit.ntri.api.recv.service.RecvApiSpec;
import cokr.xit.ntri.api.recv.service.impl.LevyCancel;
import cokr.xit.ntri.api.recv.service.impl.LevyResult;
@ -31,6 +28,7 @@ import java.util.Map;
@RestController
@Tag(name = "NtriRecvApi", description = "차세대 세외수입 개별시스템 연계")
public class NtriRecvApi {
private final RecvErrorRepository recvErrorRepository;
private final RecvLevyCancelRepository recvLevyCancelRepository;
private final RecvLevyResultRepository recvLevyResultRepository;
@ -44,7 +42,7 @@ public class NtriRecvApi {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Example..."
, summary = "부과결과정보 전송", description = "세외수입시스템 -> 개별시스템을 호출하여 데이터를 전송 한다."
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0001\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"linkMngKey\":null,\"taxnNo\":null,\"untyTaxnNo\":null,\"dptCd\":null,\"spclFisBizCd\":null,\"fyr\":null,\"actSeCd\":null,\"rprsTxmCd\":null,\"operItemCd\":null,\"lvyNo\":null,\"itmNo\":null,\"epayNo\":null,\"vtlacBankNm1\":null,\"vtlacBankNm2\":null,\"vtlacBankNm3\":null,\"vtlacBankNm4\":null,\"vtlacBankNm5\":null,\"vtlacBankNm6\":null,\"vtlacBankNm7\":null,\"vtlacBankNm8\":null,\"vtlacBankNm9\":null,\"vtlacBankNm10\":null,\"vtlacBankNm11\":null,\"vtlacBankNm12\":null,\"vtlacBankNm13\":null,\"vtlacBankNm14\":null,\"vtlacBankNm15\":null,\"vtlacBankNm16\":null,\"vtlacBankNm17\":null,\"vtlacBankNm18\":null,\"vtlacBankNm19\":null,\"vtlacBankNm20\":null,\"vrActno1\":null,\"vrActno2\":null,\"vrActno3\":null,\"vrActno4\":null,\"vrActno5\":null,\"vrActno6\":null,\"vrActno7\":null,\"vrActno8\":null,\"vrActno9\":null,\"vrActno10\":null,\"vrActno11\":null,\"vrActno12\":null,\"vrActno13\":null,\"vrActno14\":null,\"vrActno15\":null,\"vrActno16\":null,\"vrActno17\":null,\"vrActno18\":null,\"vrActno19\":null,\"vrActno20\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}}}")
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0001\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":[{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"linkMngKey\":null,\"taxnNo\":null,\"untyTaxnNo\":null,\"dptCd\":null,\"spclFisBizCd\":null,\"fyr\":null,\"actSeCd\":null,\"rprsTxmCd\":null,\"operItemCd\":null,\"lvyNo\":null,\"itmNo\":null,\"epayNo\":null,\"vtlacBankNm1\":null,\"vtlacBankNm2\":null,\"vtlacBankNm3\":null,\"vtlacBankNm4\":null,\"vtlacBankNm5\":null,\"vtlacBankNm6\":null,\"vtlacBankNm7\":null,\"vtlacBankNm8\":null,\"vtlacBankNm9\":null,\"vtlacBankNm10\":null,\"vtlacBankNm11\":null,\"vtlacBankNm12\":null,\"vtlacBankNm13\":null,\"vtlacBankNm14\":null,\"vtlacBankNm15\":null,\"vtlacBankNm16\":null,\"vtlacBankNm17\":null,\"vtlacBankNm18\":null,\"vtlacBankNm19\":null,\"vtlacBankNm20\":null,\"vrActno1\":null,\"vrActno2\":null,\"vrActno3\":null,\"vrActno4\":null,\"vrActno5\":null,\"vrActno6\":null,\"vrActno7\":null,\"vrActno8\":null,\"vrActno9\":null,\"vrActno10\":null,\"vrActno11\":null,\"vrActno12\":null,\"vrActno13\":null,\"vrActno14\":null,\"vrActno15\":null,\"vrActno16\":null,\"vrActno17\":null,\"vrActno18\":null,\"vrActno19\":null,\"vrActno20\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}]}}")
})
})
@PostMapping(value = "/recv/levy/result", produces = MediaType.APPLICATION_JSON_VALUE)
@ -54,6 +52,7 @@ public class NtriRecvApi {
RecvApiSpec recv = LevyResult.builder()
.jpaRepository(recvLevyResultRepository)
.jParam(jParam)
.recvErrorRepository(recvErrorRepository)
.build();
Map<String, Object> resultInfo = this.execute(recv, jParam);
@ -64,7 +63,7 @@ public class NtriRecvApi {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Example..."
, summary = "부과취소정보 전송", description = "세외수입시스템 -> 개별시스템을 호출하여 데이터를 전송 한다."
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0002\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"linkMngKey\":null,\"taxnNo\":null,\"lvyRtrcnYmd\":null,\"delRsnCn\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}}}")
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0002\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":[{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"linkMngKey\":null,\"taxnNo\":null,\"lvyRtrcnYmd\":null,\"delRsnCn\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}]}}")
})
})
@PostMapping(value = "/recv/levy/cancel", produces = MediaType.APPLICATION_JSON_VALUE)
@ -74,6 +73,7 @@ public class NtriRecvApi {
RecvApiSpec recv = LevyCancel.builder()
.jpaRepository(recvLevyCancelRepository)
.jParam(jParam)
.recvErrorRepository(recvErrorRepository)
.build();
Map<String, Object> resultInfo = this.execute(recv, jParam);
@ -85,7 +85,7 @@ public class NtriRecvApi {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Example..."
, summary = "수납정보 전송", description = "세외수입시스템 -> 개별시스템을 호출하여 데이터를 전송 한다."
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0003\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"sgbNm\":null,\"linkMngKey\":null,\"taxnNo\":null,\"untyTaxnNo\":null,\"dptCd\":null,\"dptNm\":null,\"spclFisBizCd\":null,\"spclFisBizNm\":null,\"fyr\":null,\"actSeCd\":null,\"actSeNm\":null,\"rprsTxmCd\":null,\"rprsTxmNm\":null,\"operItemCd\":null,\"operItemNm\":null,\"lvyNo\":null,\"itmNo\":null,\"epayNo\":null,\"rcvmtNo\":null,\"rcvmtSeCd\":null,\"rcvmtSeNm\":null,\"rcvmtYmd\":null,\"actYmd\":null,\"tsfYmd\":null,\"rcvmtPctAmt\":null,\"rcvmtAdtnAmt\":null,\"rcvmtIntrAmt\":null,\"bankNm\":null,\"rcvmtTyCd\":null,\"rcvmtTy\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}}}")
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0003\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":[{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"sgbNm\":null,\"linkMngKey\":null,\"taxnNo\":null,\"untyTaxnNo\":null,\"dptCd\":null,\"dptNm\":null,\"spclFisBizCd\":null,\"spclFisBizNm\":null,\"fyr\":null,\"actSeCd\":null,\"actSeNm\":null,\"rprsTxmCd\":null,\"rprsTxmNm\":null,\"operItemCd\":null,\"operItemNm\":null,\"lvyNo\":null,\"itmNo\":null,\"epayNo\":null,\"rcvmtNo\":null,\"rcvmtSeCd\":null,\"rcvmtSeNm\":null,\"rcvmtYmd\":null,\"actYmd\":null,\"tsfYmd\":null,\"rcvmtPctAmt\":null,\"rcvmtAdtnAmt\":null,\"rcvmtIntrAmt\":null,\"bankNm\":null,\"rcvmtTyCd\":null,\"rcvmtTy\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}]}}")
})
})
@PostMapping(value = "/recv/rciv/info", produces = MediaType.APPLICATION_JSON_VALUE)
@ -95,6 +95,7 @@ public class NtriRecvApi {
RecvApiSpec recv = RcivInfo.builder()
.jpaRepository(recvRcivInfoRepository)
.jParam(jParam)
.recvErrorRepository(recvErrorRepository)
.build();
Map<String, Object> resultInfo = this.execute(recv, jParam);
@ -106,7 +107,7 @@ public class NtriRecvApi {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Example..."
, summary = "감액정보 전송", description = "세외수입시스템 -> 개별시스템을 호출하여 데이터를 전송 한다."
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0004\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"sgbNm\":null,\"linkMngKey\":null,\"taxnNo\":null,\"untyTaxnNo\":null,\"dptCd\":null,\"dptNm\":null,\"spclFisBizCd\":null,\"spclFisBizNm\":null,\"fyr\":null,\"actSeCd\":null,\"actSeNm\":null,\"rprsTxmCd\":null,\"rprsTxmNm\":null,\"operItemCd\":null,\"operItemNm\":null,\"lvyNo\":null,\"itmNo\":null,\"rdcYmd\":null,\"rdcPctAmt\":null,\"rdcAdtnAmt\":null,\"rdcIntrAmt\":null,\"rdcAmt\":null,\"rdcRsnCn\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}}}")
, value = "{\"header\":{\"ifDate\":\"20210412103022\",\"ifMsgKey\":\"Z211103155123435-e7def4c1652a478e9c77525ab5b3ebda\",\"ifId\":\"ERR_Z000001DCP_1741000NIS_0004\",\"source\":\"3820000DCP\",\"target\":\"1741000NIS\",\"ifType\":\"S\",\"ifFormat\":\"J\",\"retName\":\"\",\"retCode\":\"200\"},\"body\":{\"reqVo\":[{\"registDt\":null,\"lastUpdtDt\":null,\"rspSgbCd\":null,\"rspLinkTrgtCd\":null,\"rspLinkMngKey\":null,\"rspLinkRstCd\":null,\"rspLinkRstMsg\":null,\"id\":null,\"sgbCd\":null,\"sgbNm\":null,\"linkMngKey\":null,\"taxnNo\":null,\"untyTaxnNo\":null,\"dptCd\":null,\"dptNm\":null,\"spclFisBizCd\":null,\"spclFisBizNm\":null,\"fyr\":null,\"actSeCd\":null,\"actSeNm\":null,\"rprsTxmCd\":null,\"rprsTxmNm\":null,\"operItemCd\":null,\"operItemNm\":null,\"lvyNo\":null,\"itmNo\":null,\"rdcYmd\":null,\"rdcPctAmt\":null,\"rdcAdtnAmt\":null,\"rdcIntrAmt\":null,\"rdcAmt\":null,\"rdcRsnCn\":null,\"rsveItem1\":null,\"rsveItem2\":null,\"rsveItem3\":null,\"rsveItem4\":null,\"rsveItem5\":null}]}}")
})
})
@PostMapping(value = "/recv/rdcamt/info", produces = MediaType.APPLICATION_JSON_VALUE)
@ -116,6 +117,7 @@ public class NtriRecvApi {
RecvApiSpec recv = RdcamtInfo.builder()
.jpaRepository(recvRdcamtInfoRepository)
.jParam(jParam)
.recvErrorRepository(recvErrorRepository)
.build();
Map<String, Object> resultInfo = this.execute(recv, jParam);
@ -136,7 +138,7 @@ public class NtriRecvApi {
//result SET
header.put("retCode", "200");
header.put("retName", "성공");
body.put("resVo", recv.getResult());
body.put("resVo", recv.getResponse());
resultInfo.put("header", header);
resultInfo.put("body", body);
} catch (JsonProcessingException e) {

@ -13,6 +13,6 @@ public interface RecvApiSpec<RT> {
void save();
RT getResult();
RT getResponse();
}

@ -1,47 +1,107 @@
package cokr.xit.ntri.api.recv.service;
import cokr.xit.ntri.api.recv.code.LinkRstCd;
import cokr.xit.ntri.api.recv.entity.RecvError;
import cokr.xit.ntri.api.recv.entity.repository.RecvErrorRepository;
import cokr.xit.ntri.api.recv.model.RecvResponseDTO;
import cokr.xit.ntri.support.utils.CmmnUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.orm.jpa.JpaSystemException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RequiredArgsConstructor
public abstract class RecvApiSupport<DATA, E, RT> implements RecvApiSpec<RT> {
public abstract class RecvApiSupport<DATA, E> implements RecvApiSpec<RecvResponseDTO> {
protected final String jParam;
protected final JpaRepository jpaRepository;
private final RecvErrorRepository recvErrorRepository;
protected ObjectMapper mapper = new ObjectMapper();
private List<DATA> datas;
private DATA data;
private E entity;
private RecvResponseDTO recvResponseDTO;
private String sgbCd;
private String linkTrgetCd;
private String linkMngKey;
@Override
public void execute() throws Exception {
String phase = null;
List<Map<String, String>> fails = new ArrayList<>();
try {
phase = "Parameter 파싱 실패";
parsing();
for (DATA data : datas) {
try {
this.data = data;
phase = "파싱 데이터 객체 매핑 실패";
mapping();
phase = "데이터 저장 실패";
save();
phase = "결과 저장 실패";
this.entity = updateResult(this.entity);
this.entity = setResult(this.entity);
save();
} catch (JpaSystemException e) {
Map<String, String> fail = this.genFail(String.format("%s. 표준연계지침의 메시지전문구성 필드의 타입과 사이즈가 다를 경우 DB에 저장 할 수 없습니다.", phase), e);
fails.add(fail);
} catch (Exception e) {
Map<String, String> fail = this.genFail(phase, e);
fails.add(fail);
Exception ex = new RuntimeException(phase, e);
this.entity = updateResult(this.entity, ex);
this.entity = setResult(this.entity, ex);
save();
}
}
// throw ex;
if (CmmnUtil.isEmpty(fails))
this.setResponse(LinkRstCd.ok, LinkRstCd.ok.getCodeNm());
else {
if (fails.size() == 1)
this.setResponse(LinkRstCd.internalFail, String.format("%s. [식별키 %s]", fails.get(0).get("errMsg"), fails.get(0).get("linkMngKey")));
else
this.setResponse(LinkRstCd.internalFail, String.format("처리에 실패 했습니다. [식별키 %s] 외 %d 건", fails.get(0).get("linkMngKey"), fails.size() - 1));
}
} catch (Exception e) {
this.setResponse(LinkRstCd.internalFail, String.format("%s. 정상적인 요청전문이 아닙니다.", phase));
} finally {
if (fails.size() > 0)
recvErrorRepository.saveAll(fails.stream()
.map(fail -> RecvError.builder()
.sgbCd(fail.get("sgbCd"))
.linkMngKey(fail.get("linkMngKey"))
.reqData(fail.get("reqData"))
.errMsg(fail.get("errMsg"))
.errDetail(fail.get("errDetail"))
.build())
.collect(Collectors.toList())
);
}
}
protected abstract DATA parsing(String jParam) throws JsonProcessingException;
private Map<String, String> genFail(String errMsg, Exception e) throws JsonProcessingException {
Map<String, String> fail = new HashMap<>();
fail.put("sgbCd", this.sgbCd);
fail.put("linkMngKey", this.linkMngKey);
fail.put("reqData", CmmnUtil.isEmpty(this.data) ? null : mapper.writeValueAsString(this.data));
fail.put("errMsg", errMsg);
fail.put("errDetail", CmmnUtil.printStackTraceToString(e));
return fail;
}
protected abstract List<DATA> parsing(String jParam) throws JsonProcessingException;
@Override
public void parsing() throws JsonProcessingException {
this.data = parsing(this.jParam);
this.datas = parsing(this.jParam);
}
@ -50,20 +110,39 @@ public abstract class RecvApiSupport<DATA, E, RT> implements RecvApiSpec<RT> {
@Override
public void mapping() {
this.entity = mapping(data);
this.sgbCd = getSgbCd(this.entity);
this.linkTrgetCd = getLinkTrgetCd(this.entity);
this.linkMngKey = getLinkMngKey(this.entity);
}
protected abstract String getSgbCd(E e);
protected abstract String getLinkTrgetCd(E e);
protected abstract String getLinkMngKey(E e);
@Override
public void save() {
this.jpaRepository.save(entity);
}
protected abstract E updateResult(E entity);
protected abstract E setResult(E entity);
protected abstract E updateResult(E entity, Exception e);
protected abstract E setResult(E entity, Exception e);
protected E getEntity() {
return this.entity;
private void setResponse(LinkRstCd linkRstCd, String linkRstMsg) {
this.recvResponseDTO = RecvResponseDTO.builder()
.sgbCd(this.sgbCd)
.linkTrgtCd(this.linkTrgetCd)
.linkMngKey(this.linkMngKey)
.linkRstCd(linkRstCd.getExtCode())
.linkRstMsg(linkRstMsg)
.build();
}
@Override
public RecvResponseDTO getResponse() {
return this.recvResponseDTO;
}
}

@ -2,25 +2,26 @@ package cokr.xit.ntri.api.recv.service.impl;
import cokr.xit.ntri.api.recv.code.LinkRstCd;
import cokr.xit.ntri.api.recv.entity.RecvLevyCancel;
import cokr.xit.ntri.api.recv.model.RecvResponseDTO;
import cokr.xit.ntri.api.recv.entity.repository.RecvErrorRepository;
import cokr.xit.ntri.api.recv.service.RecvApiSupport;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Builder;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Map;
public class LevyCancel extends RecvApiSupport<Map<String, String>, RecvLevyCancel, RecvResponseDTO> {
public class LevyCancel extends RecvApiSupport<Map<String, String>, RecvLevyCancel> {
@Builder(builderClassName = "builder")
public LevyCancel(String jParam, JpaRepository jpaRepository) {
super(jParam, jpaRepository);
public LevyCancel(String jParam, JpaRepository jpaRepository, RecvErrorRepository recvErrorRepository) {
super(jParam, jpaRepository, recvErrorRepository);
}
@Override
protected Map<String, String> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String,Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return body.get("reqVo");
protected List<Map<String, String>> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String, Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return (List<Map<String, String>>) body.get("reqVo");
}
@Override
@ -40,7 +41,22 @@ public class LevyCancel extends RecvApiSupport<Map<String, String>, RecvLevyCanc
}
@Override
protected RecvLevyCancel updateResult(RecvLevyCancel entity) {
protected String getSgbCd(RecvLevyCancel recvLevyCancel) {
return recvLevyCancel.getSgbCd();
}
@Override
protected String getLinkTrgetCd(RecvLevyCancel recvLevyCancel) {
return recvLevyCancel.getRspLinkTrgtCd();
}
@Override
protected String getLinkMngKey(RecvLevyCancel recvLevyCancel) {
return recvLevyCancel.getLinkMngKey();
}
@Override
protected RecvLevyCancel setResult(RecvLevyCancel entity) {
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
@ -50,26 +66,15 @@ public class LevyCancel extends RecvApiSupport<Map<String, String>, RecvLevyCanc
}
@Override
protected RecvLevyCancel updateResult(RecvLevyCancel entity, Exception e) {
protected RecvLevyCancel setResult(RecvLevyCancel entity, Exception e) {
if (entity == null)
entity = RecvLevyCancel.builder().build();
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
entity.setRspLinkRstCd(LinkRstCd.fail);
entity.setRspLinkRstCd(LinkRstCd.internalFail);
entity.setRspLinkRstMsg(e.getMessage());
return entity;
}
@Override
public RecvResponseDTO getResult() {
return RecvResponseDTO.builder()
.sgbCd(getEntity().getRspSgbCd())
.linkTrgtCd(getEntity().getRspLinkTrgtCd())
.linkMngKey(getEntity().getRspLinkMngKey())
.linkRstCd(getEntity().getRspLinkRstCd())
.linkRstMsg(getEntity().getRspLinkRstMsg())
.build();
}
}

@ -2,25 +2,26 @@ package cokr.xit.ntri.api.recv.service.impl;
import cokr.xit.ntri.api.recv.code.LinkRstCd;
import cokr.xit.ntri.api.recv.entity.RecvLevyResult;
import cokr.xit.ntri.api.recv.model.RecvResponseDTO;
import cokr.xit.ntri.api.recv.entity.repository.RecvErrorRepository;
import cokr.xit.ntri.api.recv.service.RecvApiSupport;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Builder;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Map;
public class LevyResult extends RecvApiSupport<Map<String, String>, RecvLevyResult, RecvResponseDTO> {
public class LevyResult extends RecvApiSupport<Map<String, String>, RecvLevyResult> {
@Builder(builderClassName = "builder")
public LevyResult(String jParam, JpaRepository jpaRepository) {
super(jParam, jpaRepository);
public LevyResult(String jParam, JpaRepository jpaRepository, RecvErrorRepository recvErrorRepository) {
super(jParam, jpaRepository, recvErrorRepository);
}
@Override
protected Map<String, String> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String,Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return body.get("reqVo");
protected List<Map<String, String>> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String, Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return (List<Map<String, String>>) body.get("reqVo");
}
@Override
@ -88,7 +89,22 @@ public class LevyResult extends RecvApiSupport<Map<String, String>, RecvLevyResu
}
@Override
protected RecvLevyResult updateResult(RecvLevyResult entity) {
protected String getSgbCd(RecvLevyResult recvLevyResult) {
return recvLevyResult.getSgbCd();
}
@Override
protected String getLinkTrgetCd(RecvLevyResult recvLevyResult) {
return recvLevyResult.getRspLinkTrgtCd();
}
@Override
protected String getLinkMngKey(RecvLevyResult recvLevyResult) {
return recvLevyResult.getLinkMngKey();
}
@Override
protected RecvLevyResult setResult(RecvLevyResult entity) {
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
@ -98,26 +114,15 @@ public class LevyResult extends RecvApiSupport<Map<String, String>, RecvLevyResu
}
@Override
protected RecvLevyResult updateResult(RecvLevyResult entity, Exception e) {
protected RecvLevyResult setResult(RecvLevyResult entity, Exception e) {
if (entity == null)
entity = RecvLevyResult.builder().build();
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
entity.setRspLinkRstCd(LinkRstCd.fail);
entity.setRspLinkRstCd(LinkRstCd.internalFail);
entity.setRspLinkRstMsg(e.getMessage());
return entity;
}
@Override
public RecvResponseDTO getResult() {
return RecvResponseDTO.builder()
.sgbCd(getEntity().getRspSgbCd())
.linkTrgtCd(getEntity().getRspLinkTrgtCd())
.linkMngKey(getEntity().getRspLinkMngKey())
.linkRstCd(getEntity().getRspLinkRstCd())
.linkRstMsg(getEntity().getRspLinkRstMsg())
.build();
}
}

@ -2,25 +2,26 @@ package cokr.xit.ntri.api.recv.service.impl;
import cokr.xit.ntri.api.recv.code.LinkRstCd;
import cokr.xit.ntri.api.recv.entity.RecvRcivInfo;
import cokr.xit.ntri.api.recv.model.RecvResponseDTO;
import cokr.xit.ntri.api.recv.entity.repository.RecvErrorRepository;
import cokr.xit.ntri.api.recv.service.RecvApiSupport;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Builder;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Map;
public class RcivInfo extends RecvApiSupport<Map<String, String>, RecvRcivInfo, RecvResponseDTO> {
public class RcivInfo extends RecvApiSupport<Map<String, String>, RecvRcivInfo> {
@Builder(builderClassName = "builder")
public RcivInfo(String jParam, JpaRepository jpaRepository) {
super(jParam, jpaRepository);
public RcivInfo(String jParam, JpaRepository jpaRepository, RecvErrorRepository recvErrorRepository) {
super(jParam, jpaRepository, recvErrorRepository);
}
@Override
protected Map<String, String> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String,Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return body.get("reqVo");
protected List<Map<String, String>> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String, Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return (List<Map<String, String>>) body.get("reqVo");
}
@Override
@ -66,7 +67,22 @@ public class RcivInfo extends RecvApiSupport<Map<String, String>, RecvRcivInfo,
}
@Override
protected RecvRcivInfo updateResult(RecvRcivInfo entity) {
protected String getSgbCd(RecvRcivInfo recvRcivInfo) {
return recvRcivInfo.getSgbCd();
}
@Override
protected String getLinkTrgetCd(RecvRcivInfo recvRcivInfo) {
return recvRcivInfo.getRspLinkTrgtCd();
}
@Override
protected String getLinkMngKey(RecvRcivInfo recvRcivInfo) {
return recvRcivInfo.getLinkMngKey();
}
@Override
protected RecvRcivInfo setResult(RecvRcivInfo entity) {
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
@ -76,26 +92,15 @@ public class RcivInfo extends RecvApiSupport<Map<String, String>, RecvRcivInfo,
}
@Override
protected RecvRcivInfo updateResult(RecvRcivInfo entity, Exception e) {
protected RecvRcivInfo setResult(RecvRcivInfo entity, Exception e) {
if (entity == null)
entity = RecvRcivInfo.builder().build();
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
entity.setRspLinkRstCd(LinkRstCd.fail);
entity.setRspLinkRstCd(LinkRstCd.internalFail);
entity.setRspLinkRstMsg(e.getMessage());
return entity;
}
@Override
public RecvResponseDTO getResult() {
return RecvResponseDTO.builder()
.sgbCd(getEntity().getRspSgbCd())
.linkTrgtCd(getEntity().getRspLinkTrgtCd())
.linkMngKey(getEntity().getRspLinkMngKey())
.linkRstCd(getEntity().getRspLinkRstCd())
.linkRstMsg(getEntity().getRspLinkRstMsg())
.build();
}
}

@ -2,25 +2,26 @@ package cokr.xit.ntri.api.recv.service.impl;
import cokr.xit.ntri.api.recv.code.LinkRstCd;
import cokr.xit.ntri.api.recv.entity.RecvRdcamtInfo;
import cokr.xit.ntri.api.recv.model.RecvResponseDTO;
import cokr.xit.ntri.api.recv.entity.repository.RecvErrorRepository;
import cokr.xit.ntri.api.recv.service.RecvApiSupport;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Builder;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Map;
public class RdcamtInfo extends RecvApiSupport<Map<String, String>, RecvRdcamtInfo, RecvResponseDTO> {
public class RdcamtInfo extends RecvApiSupport<Map<String, String>, RecvRdcamtInfo> {
@Builder(builderClassName = "builder")
public RdcamtInfo(String jParam, JpaRepository jpaRepository) {
super(jParam, jpaRepository);
public RdcamtInfo(String jParam, JpaRepository jpaRepository, RecvErrorRepository recvErrorRepository) {
super(jParam, jpaRepository, recvErrorRepository);
}
@Override
protected Map<String, String> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String,Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return body.get("reqVo");
protected List<Map<String, String>> parsing(String jParam) throws JsonProcessingException {
Map<String, Map<String, String>> body = (Map<String, Map<String, String>>) mapper.readValue(jParam, Map.class).get("body");
return (List<Map<String, String>>) body.get("reqVo");
}
@Override
@ -59,7 +60,22 @@ public class RdcamtInfo extends RecvApiSupport<Map<String, String>, RecvRdcamtIn
}
@Override
protected RecvRdcamtInfo updateResult(RecvRdcamtInfo entity) {
protected String getSgbCd(RecvRdcamtInfo recvRdcamtInfo) {
return recvRdcamtInfo.getSgbCd();
}
@Override
protected String getLinkTrgetCd(RecvRdcamtInfo recvRdcamtInfo) {
return recvRdcamtInfo.getRspLinkTrgtCd();
}
@Override
protected String getLinkMngKey(RecvRdcamtInfo recvRdcamtInfo) {
return recvRdcamtInfo.getLinkMngKey();
}
@Override
protected RecvRdcamtInfo setResult(RecvRdcamtInfo entity) {
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
@ -69,26 +85,15 @@ public class RdcamtInfo extends RecvApiSupport<Map<String, String>, RecvRdcamtIn
}
@Override
protected RecvRdcamtInfo updateResult(RecvRdcamtInfo entity, Exception e) {
protected RecvRdcamtInfo setResult(RecvRdcamtInfo entity, Exception e) {
if (entity == null)
entity = RecvRdcamtInfo.builder().build();
entity.setRspSgbCd(entity.getSgbCd());
entity.setRspLinkTrgtCd("LinkTrgtCd");
entity.setRspLinkMngKey(entity.getLinkMngKey());
entity.setRspLinkRstCd(LinkRstCd.fail);
entity.setRspLinkRstCd(LinkRstCd.internalFail);
entity.setRspLinkRstMsg(e.getMessage());
return entity;
}
@Override
public RecvResponseDTO getResult() {
return RecvResponseDTO.builder()
.sgbCd(getEntity().getRspSgbCd())
.linkTrgtCd(getEntity().getRspLinkTrgtCd())
.linkMngKey(getEntity().getRspLinkMngKey())
.linkRstCd(getEntity().getRspLinkRstCd())
.linkRstMsg(getEntity().getRspLinkRstMsg())
.build();
}
}

@ -33,7 +33,7 @@ spring:
jpa:
database-platform: org.hibernate.dialect.Oracle10gDialect
hibernate:
ddl-auto: none # create / create-drop / update / validate / none
ddl-auto: update # create / create-drop / update / validate / none
properties:
hibernate:
format_sql: true
@ -51,8 +51,6 @@ spring:
connection-test-query: SELECT 1 FROM DUAL
transaction-isolation: TRANSACTION_READ_COMMITTED
pool-name: pool-${app.name}
# data-source-properties:
# rewriteBatchedStatments: true #???? insert ??? ??? ??
hikari:
driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url}
@ -72,18 +70,6 @@ logging:
file: utf-8
level:
root: info
'[org.hibernate.type.descriptor.sql]': trace #jpa "?" ??(binding ????) ??
# '[org.springframework.orm.jpa]': debug
# '[org.springframework.transaction]': debug
# '[org.springframework.transaction.interceptor]': trace
# '[org.springframework.jdbc.core]': off
# '[org.springframework.orm]': off
# '[org.springframework.orm.hibernate5]': off
# '[com.p6spy.engine.logging]': off
# '[com.p6spy]': off
# '[org.hibernate]': off
# '[org.hibernate.sql]': off
# '[org.hibernate.jpa]': off
exception-conversion-word: '%wEx'
pattern:
console: '%d{yyyy-MM-dd HH:mm:ss.SSS} %clr(${LOG_LEVEL_PATTERN:-%5p}){green} %clr([%18thread]){magenta} %clr(%-40.40logger{39}%line){cyan} %clr(: %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}){faint}'
@ -94,19 +80,3 @@ logging:
file-name-pattern: ${LOG_FILE}.%d{yyyy-MM-dd}-%i.log
max-history: 30 #????
max-file-size: 100MB #????
# '[org.hibernate.type.descriptor.sql]': trace
# '[org.springframework]': debug
# '[org.hibernate]': info
# ===================================================================================================================================
# Springdoc
# ===================================================================================================================================
springdoc:
swagger-ui:
path: /swagger-ui.html
group-configs:
- group: 실시간 수신
paths-to-match:
- /recv/**

@ -79,7 +79,7 @@ spring:
hibernate:
format_sql: true
use_sql_comments: true
show-sql: true
show-sql: false
datasource:
driver-class-name: ${app.datasource.driver:oracle.jdbc.OracleDriver}
# url: jdbc:oracle:thin:@${app.datasource.ip:211.119.124.117}:${app.datasource.port:1521}:${app.datasource.sid:ora11g}
@ -93,8 +93,6 @@ spring:
connection-test-query: SELECT 1 FROM DUAL
transaction-isolation: TRANSACTION_READ_COMMITTED
pool-name: pool-${app.name}
# data-source-properties:
# rewriteBatchedStatments: true #???? insert ??? ??? ??
hikari:
driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url}
@ -114,18 +112,6 @@ logging:
file: utf-8
level:
root: info
'[org.hibernate.type.descriptor.sql]': trace #jpa "?" ??(binding ????) ??
# '[org.springframework.orm.jpa]': debug
# '[org.springframework.transaction]': debug
# '[org.springframework.transaction.interceptor]': trace
# '[org.springframework.jdbc.core]': off
# '[org.springframework.orm]': off
# '[org.springframework.orm.hibernate5]': off
# '[com.p6spy.engine.logging]': off
# '[com.p6spy]': off
# '[org.hibernate]': off
# '[org.hibernate.sql]': off
# '[org.hibernate.jpa]': off
exception-conversion-word: '%wEx'
pattern:
console: '%d{yyyy-MM-dd HH:mm:ss.SSS} %clr(${LOG_LEVEL_PATTERN:-%5p}){green} %clr([%18thread]){magenta} %clr(%-40.40logger{39}%line){cyan} %clr(: %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}){faint}'
@ -136,19 +122,3 @@ logging:
file-name-pattern: ${LOG_FILE}.%d{yyyy-MM-dd}-%i.log
max-history: 30 #????
max-file-size: 100MB #????
# '[org.hibernate.type.descriptor.sql]': trace
# '[org.springframework]': debug
# '[org.hibernate]': info
# ===================================================================================================================================
# Springdoc
# ===================================================================================================================================
springdoc:
swagger-ui:
path: /swagger-ui.html
group-configs:
- group: 실시간 수신
paths-to-match:
- /recv/**

@ -53,7 +53,7 @@ spring:
database-platform: org.hibernate.dialect.Oracle10gDialect
generate-ddl: false
hibernate:
ddl-auto: none # create / create-drop / update / validate / none
ddl-auto: update # create / create-drop / update / validate / none
properties:
hibernate:
format_sql: true
@ -92,7 +92,7 @@ logging:
file: utf-8
level:
root: info
'[org.hibernate.type.descriptor.sql]': trace #jpa "?" ??(binding ????) ??
# '[org.hibernate.type.descriptor.sql]': trace #jpa "?" ??(binding ????) ??
# '[org.springframework.orm.jpa]': debug
# '[org.springframework.transaction]': debug
# '[org.springframework.transaction.interceptor]': trace

Loading…
Cancel
Save