diff --git a/pom.xml b/pom.xml
index a3b6013..f5d19dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
- 17
+ 23
diff --git a/src/main/java/de/avatic/taric/controller/TariffController.java b/src/main/java/de/avatic/taric/controller/TariffController.java
index d0cc329..3cd7cd0 100644
--- a/src/main/java/de/avatic/taric/controller/TariffController.java
+++ b/src/main/java/de/avatic/taric/controller/TariffController.java
@@ -1,6 +1,7 @@
package de.avatic.taric.controller;
import de.avatic.taric.service.TariffService;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -18,10 +19,8 @@ public class TariffController {
}
@GetMapping("")
- public void getTariffRate(@RequestParam String hsCode, @RequestParam String countryCode) {
-
- tariffService.importTariffs( hsCode, countryCode);
-
+ public ResponseEntity getTariffRate(@RequestParam String hsCode, @RequestParam String countryCode) {
+ return tariffService.importTariffs( hsCode, countryCode).map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}
}
diff --git a/src/main/java/de/avatic/taric/controller/TariffController2.java b/src/main/java/de/avatic/taric/controller/TariffController2.java
index 4667f3e..753a35f 100644
--- a/src/main/java/de/avatic/taric/controller/TariffController2.java
+++ b/src/main/java/de/avatic/taric/controller/TariffController2.java
@@ -1,7 +1,7 @@
package de.avatic.taric.controller;
import de.avatic.taric.service.TariffService2;
-import de.avatic.taric.service.TariffService2.TariffResult;
+//import de.avatic.taric.service.TariffService2.TariffResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -23,109 +23,109 @@ import java.util.Map;
@Tag(name = "Tariff API", description = "API zur Abfrage von Zolltarifen")
public class TariffController2 {
- private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TariffController2.class);
-
- private final TariffService2 tariffService;
-
- public TariffController2(TariffService2 tariffService) {
- this.tariffService = tariffService;
- }
-
- @GetMapping("/rate")
- @Operation(summary = "Zolltarif abfragen",
- description = "Ermittelt den Zolltarif für einen HS-Code und ein Herkunftsland")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Tarif erfolgreich gefunden"),
- @ApiResponse(responseCode = "404", description = "Kein Tarif gefunden"),
- @ApiResponse(responseCode = "400", description = "Ungültige Eingabeparameter")
- })
- public ResponseEntity getTariffRate(
- @Parameter(description = "HS-Code (6, 8 oder 10 Stellen)", example = "850410")
- @RequestParam
- @NotBlank(message = "HS Code ist erforderlich")
- @Pattern(regexp = "^[0-9]{4,10}$", message = "HS Code muss 4-10 Ziffern enthalten")
- String hsCode,
-
- @Parameter(description = "ISO-2 Ländercode", example = "CN")
- @RequestParam
- @NotBlank(message = "Ländercode ist erforderlich")
- @Pattern(regexp = "^[A-Z]{2}$", message = "Ländercode muss 2 Großbuchstaben sein")
- String countryCode) {
-
- log.info("Tariff rate request - HS Code: {}, Country: {}", hsCode, countryCode);
-
- try {
- TariffResult result = tariffService.getTariffRate(hsCode, countryCode);
-
- if (result.isFound()) {
- TariffResponse response = TariffResponse.success(
- result.getRate(),
- result.getHsCode(),
- result.getCountryCode()
- );
- return ResponseEntity.ok(response);
- } else {
- TariffResponse response = TariffResponse.notFound(result.getMessage());
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
- }
-
- } catch (Exception e) {
- log.error("Error getting tariff rate", e);
- TariffResponse response = TariffResponse.error("Internal server error: " + e.getMessage());
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
- }
- }
-
- @GetMapping("/health")
- @Operation(summary = "Health Check", description = "Prüft ob der Service verfügbar ist")
- public ResponseEntity