|
|
|
|
@ -5,9 +5,6 @@ import go.kr.project.api.model.response.BasicResponse;
|
|
|
|
|
import go.kr.project.api.model.Envelope;
|
|
|
|
|
import go.kr.project.api.model.request.LedgerRequest;
|
|
|
|
|
import go.kr.project.api.model.response.LedgerResponse;
|
|
|
|
|
import go.kr.project.api.internal.service.VmisCarBassMatterInqireService;
|
|
|
|
|
import go.kr.project.api.internal.service.VmisCarLedgerFrmbkService;
|
|
|
|
|
import go.kr.project.api.config.properties.VmisProperties;
|
|
|
|
|
import go.kr.project.api.model.VehicleApiResponseVO;
|
|
|
|
|
import go.kr.project.api.service.VehicleInfoService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
@ -27,6 +24,7 @@ import java.util.Collections;
|
|
|
|
|
* 자동차 정보 연계 REST 컨트롤러 (Swagger 문서화 및 테스트용)
|
|
|
|
|
*
|
|
|
|
|
* <p>설정(vmis.integration.mode)에 따라 Internal/External 모드로 분기하여 호출합니다.</p>
|
|
|
|
|
* <p>중요: 모드별 분기는 VehicleInfoService 구현체가 자동으로 처리하므로, 컨트롤러는 단순히 서비스에 위임합니다.</p>
|
|
|
|
|
*
|
|
|
|
|
* <h3>모드별 자동 분기:</h3>
|
|
|
|
|
* <ul>
|
|
|
|
|
@ -50,15 +48,7 @@ import java.util.Collections;
|
|
|
|
|
@Tag(name = "VMIS 차량정보 (Swagger)", description = "vmis.integration.mode에 따라 내부/외부 분기 호출")
|
|
|
|
|
public class VehicleInterfaceController {
|
|
|
|
|
|
|
|
|
|
private final VmisCarBassMatterInqireService carBassMatterInqireService; // Internal 전용 서비스
|
|
|
|
|
private final VmisCarLedgerFrmbkService carLedgerFrmbkService; // Internal 전용 서비스
|
|
|
|
|
private final VehicleInfoService vehicleInfoService; // 모드별 구현체 주입 (통합 조회)
|
|
|
|
|
private final VmisProperties vmisProperties; // 모드 확인용
|
|
|
|
|
|
|
|
|
|
// 내부 유틸: 현재 External 모드 여부
|
|
|
|
|
private boolean isExternalMode() {
|
|
|
|
|
return "external".equalsIgnoreCase(vmisProperties.getIntegration().getMode());
|
|
|
|
|
}
|
|
|
|
|
private final VehicleInfoService vehicleInfoService; // 모드별 구현체 자동 주입
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 자동차 기본정보 + 등록원부(갑) 통합 조회
|
|
|
|
|
@ -97,19 +87,18 @@ public class VehicleInterfaceController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 자동차 기본사항만 조회
|
|
|
|
|
* - Internal: 정부 API 형식 서비스 호출 그대로 반환
|
|
|
|
|
* - External: VehicleInfoService 통합 호출 후 BasicResponse만 Envelope로 감싸 반환
|
|
|
|
|
* - 중요 로직: VehicleInfoService에 완전히 위임하여 모드별 분기는 서비스 구현체가 자동 처리
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(value = "/basic.ajax", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
@Operation(
|
|
|
|
|
summary = "자동차기본사항조회 (단독)",
|
|
|
|
|
description = "Internal 모드는 정부 API 형식 그대로, External 모드는 외부 REST 결과에서 기본정보만 반환",
|
|
|
|
|
description = "vmis.integration.mode에 따라 내부 모듈 또는 외부 REST API를 통해 기본정보만 조회",
|
|
|
|
|
requestBody = @RequestBody(
|
|
|
|
|
content = @Content(
|
|
|
|
|
mediaType = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
examples = @ExampleObject(
|
|
|
|
|
name = "기본사항조회 예제",
|
|
|
|
|
value = "{\"data\": [{\"INFO_SYS_ID\": \"41-345\", \"VHRNO\": \"12가3456\"}]}"
|
|
|
|
|
value = "{\"data\": [{\"VHRNO\": \"12가3456\"}]}"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
@ -117,16 +106,13 @@ public class VehicleInterfaceController {
|
|
|
|
|
public ResponseEntity<Envelope<BasicResponse>> basic(
|
|
|
|
|
@org.springframework.web.bind.annotation.RequestBody Envelope<BasicRequest> envelope
|
|
|
|
|
) {
|
|
|
|
|
if (!isExternalMode()) {
|
|
|
|
|
// Internal 모드: 정부 API 형식 그대로 위임
|
|
|
|
|
return carBassMatterInqireService.basic(envelope);
|
|
|
|
|
}
|
|
|
|
|
// External 모드: 통합 서비스에서 기본정보만 추출하여 Envelope 형태로 반환
|
|
|
|
|
// 중요 로직: Swagger 요청 Envelope에서 차량번호 추출
|
|
|
|
|
String vhrno = (envelope != null && !envelope.getData().isEmpty()) ? envelope.getData().get(0).getVhrno() : null;
|
|
|
|
|
if (vhrno == null || vhrno.trim().isEmpty()) {
|
|
|
|
|
return ResponseEntity.ok(new Envelope<>(Collections.emptyList()));
|
|
|
|
|
}
|
|
|
|
|
// 외부 모드: 서비스 계층의 단독 메서드를 직접 호출하여 반환 (주먹구구식 분리 제거)
|
|
|
|
|
|
|
|
|
|
// VehicleInfoService는 모드에 따라 구현체가 자동 주입되어 분기 처리
|
|
|
|
|
BasicResponse basic = vehicleInfoService.getBasicInfo(vhrno);
|
|
|
|
|
Envelope<BasicResponse> out = (basic != null) ? new Envelope<>(basic) : new Envelope<>(Collections.emptyList());
|
|
|
|
|
return ResponseEntity.ok(out);
|
|
|
|
|
@ -134,19 +120,18 @@ public class VehicleInterfaceController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 자동차 등록원부(갑)만 조회
|
|
|
|
|
* - Internal: 정부 API 형식 서비스 호출 그대로 반환
|
|
|
|
|
* - External: VehicleInfoService 통합 호출 후 LedgerResponse만 Envelope로 감싸 반환
|
|
|
|
|
* - 중요 로직: VehicleInfoService에 완전히 위임하여 모드별 분기는 서비스 구현체가 자동 처리
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(value = "/ledger.ajax", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
@Operation(
|
|
|
|
|
summary = "자동차등록원부(갑) 조회 (단독)",
|
|
|
|
|
description = "Internal 모드는 정부 API 형식 그대로, External 모드는 외부 REST 결과에서 등록원부만 반환",
|
|
|
|
|
description = "vmis.integration.mode에 따라 내부 모듈 또는 외부 REST API를 통해 등록원부만 조회",
|
|
|
|
|
requestBody = @RequestBody(
|
|
|
|
|
content = @Content(
|
|
|
|
|
mediaType = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
examples = @ExampleObject(
|
|
|
|
|
name = "등록원부 조회 예제",
|
|
|
|
|
value = "{\"data\": [{\"INFO_SYS_ID\": \"41-345\", \"VHRNO\": \"12가3456\"}]}"
|
|
|
|
|
value = "{\"data\": [{\"VHRNO\": \"12가3456\"}]}"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
@ -154,16 +139,13 @@ public class VehicleInterfaceController {
|
|
|
|
|
public ResponseEntity<Envelope<LedgerResponse>> ledger(
|
|
|
|
|
@org.springframework.web.bind.annotation.RequestBody Envelope<LedgerRequest> envelope
|
|
|
|
|
) {
|
|
|
|
|
if (!isExternalMode()) {
|
|
|
|
|
// Internal 모드: 정부 API 형식 그대로 위임
|
|
|
|
|
return carLedgerFrmbkService.ledger(envelope);
|
|
|
|
|
}
|
|
|
|
|
// External 모드: 통합 서비스에서 등록원부만 추출하여 Envelope 형태로 반환
|
|
|
|
|
// 중요 로직: Swagger 요청 Envelope에서 차량번호 추출
|
|
|
|
|
String vhrno = (envelope != null && !envelope.getData().isEmpty()) ? envelope.getData().get(0).getVhrno() : null;
|
|
|
|
|
if (vhrno == null || vhrno.trim().isEmpty()) {
|
|
|
|
|
return ResponseEntity.ok(new Envelope<>(Collections.emptyList()));
|
|
|
|
|
}
|
|
|
|
|
// 외부 모드: 서비스 계층의 단독 메서드를 직접 호출하여 반환 (주먹구구식 분리 제거)
|
|
|
|
|
|
|
|
|
|
// VehicleInfoService는 모드에 따라 구현체가 자동 주입되어 분기 처리
|
|
|
|
|
LedgerResponse ledger = vehicleInfoService.getLedgerInfo(vhrno);
|
|
|
|
|
Envelope<LedgerResponse> out = (ledger != null) ? new Envelope<>(ledger) : new Envelope<>(Collections.emptyList());
|
|
|
|
|
return ResponseEntity.ok(out);
|
|
|
|
|
|