From 6391683959d967affd0ff3c1f9066995632be07e Mon Sep 17 00:00:00 2001 From: HYOJIN Date: Fri, 27 Mar 2026 09:23:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B0=99=EC=9D=80=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=EC=97=90=20=EC=83=88=20=EC=97=94=EB=93=9C=ED=8F=AC?= =?UTF-8?q?=EC=9D=B8=ED=8A=B8=20=EC=B6=94=EA=B0=80=20=EC=8B=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=83=9D=EC=84=B1=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Controller는 항상 재생성 (모든 엔드포인트 합산 파일) - Service/DTO는 이미 존재하면 스킵, force=true면 재생성 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../controller/ComplianceController.java | 39 ------ .../compliance/dto/ComplianceBypassDto.java | 122 ------------------ .../service/ComplianceBypassService.java | 35 ----- .../batch/service/BypassCodeGenerator.java | 28 +++- 4 files changed, 21 insertions(+), 203 deletions(-) delete mode 100644 src/main/java/com/snp/batch/jobs/web/compliance/controller/ComplianceController.java delete mode 100644 src/main/java/com/snp/batch/jobs/web/compliance/dto/ComplianceBypassDto.java delete mode 100644 src/main/java/com/snp/batch/jobs/web/compliance/service/ComplianceBypassService.java diff --git a/src/main/java/com/snp/batch/jobs/web/compliance/controller/ComplianceController.java b/src/main/java/com/snp/batch/jobs/web/compliance/controller/ComplianceController.java deleted file mode 100644 index f88b107..0000000 --- a/src/main/java/com/snp/batch/jobs/web/compliance/controller/ComplianceController.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.snp.batch.jobs.web.compliance.controller; - -import com.snp.batch.jobs.web.compliance.dto.ComplianceBypassDto; -import com.snp.batch.jobs.web.compliance.service.ComplianceBypassService; -import com.snp.batch.common.web.ApiResponse; -import com.snp.batch.common.web.controller.BaseBypassController; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * IMO 기반 선박 Compliance 조회 bypass API - * S&P Maritime API에서 데이터를 실시간 조회하여 그대로 반환 - */ -@RestController -@RequestMapping("/api/compliance") -@RequiredArgsConstructor -@Tag(name = "Compliance", description = "IMO 기반 선박 Compliance 조회 bypass API") -public class ComplianceController extends BaseBypassController { - - private final ComplianceBypassService complianceBypassService; - - @Operation( - summary = "IMO 기반 선박 Compliance 조회 조회", - description = "S&P API에서 IMO 기반 선박 Compliance 조회 데이터를 요청하고 응답을 그대로 반환합니다." - ) - @GetMapping("/CompliancesByImos") - public ResponseEntity>> getComplianceData(@Parameter(description = "IMO(최대 100개)") - @RequestParam(required = true) String imos) { - return execute(() -> complianceBypassService.getComplianceData(imos)); - } -} diff --git a/src/main/java/com/snp/batch/jobs/web/compliance/dto/ComplianceBypassDto.java b/src/main/java/com/snp/batch/jobs/web/compliance/dto/ComplianceBypassDto.java deleted file mode 100644 index 600d35d..0000000 --- a/src/main/java/com/snp/batch/jobs/web/compliance/dto/ComplianceBypassDto.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.snp.batch.jobs.web.compliance.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ComplianceBypassDto { - - @JsonProperty("dateAmended") - private String dateAmended; - - @JsonProperty("legalOverall") - private Integer legalOverall; - - @JsonProperty("lrimoShipNo") - private String lrimoShipNo; - - @JsonProperty("shipBESSanctionList") - private Integer shipBESSanctionList; - - @JsonProperty("shipDarkActivityIndicator") - private Integer shipDarkActivityIndicator; - - @JsonProperty("shipDetailsNoLongerMaintained") - private Integer shipDetailsNoLongerMaintained; - - @JsonProperty("shipEUSanctionList") - private Integer shipEUSanctionList; - - @JsonProperty("shipFlagDisputed") - private Integer shipFlagDisputed; - - @JsonProperty("shipFlagSanctionedCountry") - private Integer shipFlagSanctionedCountry; - - @JsonProperty("shipHistoricalFlagSanctionedCountry") - private Integer shipHistoricalFlagSanctionedCountry; - - @JsonProperty("shipOFACAdvisoryList") - private Integer shipOFACAdvisoryList; - - @JsonProperty("shipOFACNonSDNSanctionList") - private Integer shipOFACNonSDNSanctionList; - - @JsonProperty("shipOFACSanctionList") - private Integer shipOFACSanctionList; - - @JsonProperty("shipOwnerAustralianSanctionList") - private Integer shipOwnerAustralianSanctionList; - - @JsonProperty("shipOwnerBESSanctionList") - private Integer shipOwnerBESSanctionList; - - @JsonProperty("shipOwnerCanadianSanctionList") - private Integer shipOwnerCanadianSanctionList; - - @JsonProperty("shipOwnerEUSanctionList") - private Integer shipOwnerEUSanctionList; - - @JsonProperty("shipOwnerFATFJurisdiction") - private Integer shipOwnerFATFJurisdiction; - - @JsonProperty("shipOwnerHistoricalOFACSanctionedCountry") - private Integer shipOwnerHistoricalOFACSanctionedCountry; - - @JsonProperty("shipOwnerOFACSSIList") - private Integer shipOwnerOFACSSIList; - - @JsonProperty("shipOwnerOFACSanctionList") - private Integer shipOwnerOFACSanctionList; - - @JsonProperty("shipOwnerOFACSanctionedCountry") - private Integer shipOwnerOFACSanctionedCountry; - - @JsonProperty("shipOwnerParentCompanyNonCompliance") - private Integer shipOwnerParentCompanyNonCompliance; - - @JsonProperty("shipOwnerParentFATFJurisdiction") - private String shipOwnerParentFATFJurisdiction; - - @JsonProperty("shipOwnerParentOFACSanctionedCountry") - private String shipOwnerParentOFACSanctionedCountry; - - @JsonProperty("shipOwnerSwissSanctionList") - private Integer shipOwnerSwissSanctionList; - - @JsonProperty("shipOwnerUAESanctionList") - private Integer shipOwnerUAESanctionList; - - @JsonProperty("shipOwnerUNSanctionList") - private Integer shipOwnerUNSanctionList; - - @JsonProperty("shipSTSPartnerNonComplianceLast12m") - private Integer shipSTSPartnerNonComplianceLast12m; - - @JsonProperty("shipSanctionedCountryPortCallLast12m") - private Integer shipSanctionedCountryPortCallLast12m; - - @JsonProperty("shipSanctionedCountryPortCallLast3m") - private Integer shipSanctionedCountryPortCallLast3m; - - @JsonProperty("shipSanctionedCountryPortCallLast6m") - private Integer shipSanctionedCountryPortCallLast6m; - - @JsonProperty("shipSecurityLegalDisputeEvent") - private Integer shipSecurityLegalDisputeEvent; - - @JsonProperty("shipSwissSanctionList") - private Integer shipSwissSanctionList; - - @JsonProperty("shipUNSanctionList") - private Integer shipUNSanctionList; - -} diff --git a/src/main/java/com/snp/batch/jobs/web/compliance/service/ComplianceBypassService.java b/src/main/java/com/snp/batch/jobs/web/compliance/service/ComplianceBypassService.java deleted file mode 100644 index 67f27d2..0000000 --- a/src/main/java/com/snp/batch/jobs/web/compliance/service/ComplianceBypassService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.snp.batch.jobs.web.compliance.service; - -import com.snp.batch.jobs.web.compliance.dto.ComplianceBypassDto; -import com.snp.batch.common.web.service.BaseBypassService; -import java.util.List; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.stereotype.Service; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * IMO 기반 선박 Compliance 조회 bypass 서비스 - * 외부 Maritime API에서 데이터를 실시간 조회하여 그대로 반환 - */ -@Service -public class ComplianceBypassService extends BaseBypassService { - - public ComplianceBypassService( - @Qualifier("maritimeServiceApiWebClient") WebClient webClient) { - super(webClient, "/RiskAndCompliance/CompliancesByImos", "IMO 기반 선박 Compliance 조회", - new ParameterizedTypeReference<>() {}, - new ParameterizedTypeReference<>() {}); - } - - /** - * IMO 기반 선박 Compliance 조회 데이터를 조회합니다. - * - * @return IMO 기반 선박 Compliance 조회 - */ - public List getComplianceData(String imos) { - return fetchGetList(uri -> uri.path(getApiPath()) - .queryParam("imos", imos) - .build()); - } -} diff --git a/src/main/java/com/snp/batch/service/BypassCodeGenerator.java b/src/main/java/com/snp/batch/service/BypassCodeGenerator.java index 0b4049d..bf9d5a6 100644 --- a/src/main/java/com/snp/batch/service/BypassCodeGenerator.java +++ b/src/main/java/com/snp/batch/service/BypassCodeGenerator.java @@ -50,20 +50,34 @@ public class BypassCodeGenerator { for (BypassApiConfig config : configs) { String endpointName = config.getEndpointName(); - String dtoCode = generateDtoCode(domain, endpointName, config.getFields()); - String serviceCode = generateServiceCode(domain, endpointName, config, config.getParams()); + String dtoPath = basePath + "/dto/" + endpointName + "Dto.java"; + String servicePath = basePath + "/service/" + endpointName + "Service.java"; - Path dtoFilePath = writeFile(basePath + "/dto/" + endpointName + "Dto.java", dtoCode, force); - Path serviceFilePath = writeFile(basePath + "/service/" + endpointName + "Service.java", serviceCode, force); + // Service/DTO: 이미 존재하면 스킵 (force=true면 재생성) + if (!force && Files.exists(Path.of(dtoPath))) { + log.info("DTO 파일 이미 존재, 스킵: {}", dtoPath); + dtoPaths.add(dtoPath); + } else { + String dtoCode = generateDtoCode(domain, endpointName, config.getFields()); + Path dtoFilePath = writeFile(dtoPath, dtoCode, true); + dtoPaths.add(dtoFilePath.toString()); + } - dtoPaths.add(dtoFilePath.toString()); - servicePaths.add(serviceFilePath.toString()); + if (!force && Files.exists(Path.of(servicePath))) { + log.info("Service 파일 이미 존재, 스킵: {}", servicePath); + servicePaths.add(servicePath); + } else { + String serviceCode = generateServiceCode(domain, endpointName, config, config.getParams()); + Path serviceFilePath = writeFile(servicePath, serviceCode, true); + servicePaths.add(serviceFilePath.toString()); + } } + // Controller: 모든 엔드포인트를 합치므로 항상 재생성 String controllerCode = generateControllerCode(domain, configs); String domainCapitalized = capitalize(domain); Path controllerFilePath = writeFile( - basePath + "/controller/" + domainCapitalized + "Controller.java", controllerCode, force); + basePath + "/controller/" + domainCapitalized + "Controller.java", controllerCode, true); log.info("코드 생성 완료 - domain: {}, endpoints: {}, controller: {}", domain, configs.stream().map(BypassApiConfig::getEndpointName).toList(), controllerFilePath);