diff --git a/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java b/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java index c1436e47..75eb756f 100644 --- a/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java +++ b/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java @@ -24,6 +24,7 @@ public class BatchScheduler { @Scheduled(cron = "0 0 2,5,8,11,14,17,20,23 * * *") // 3시간마다 public void runDailyWeatherJob() { + log.info("[ Scheduler ] DailyWeather Api"); try { JobParameters jobParameters = new JobParametersBuilder() .addLong("executedTime", System.currentTimeMillis()) @@ -37,6 +38,7 @@ public void runDailyWeatherJob() { @Scheduled(cron = "0 0 * * * *") // 1시간마다 public void runExpectedWeatherJob() { + log.info("[ Scheduler ] ExpectedWeather Api"); try { JobParameters jobParameters = new JobParametersBuilder() .addLong("executedTime", System.currentTimeMillis()) diff --git a/weather-service/src/main/java/com/waither/weatherservice/controller/WeatherController.java b/weather-service/src/main/java/com/waither/weatherservice/controller/WeatherController.java index 2e87619e..cdc3163b 100644 --- a/weather-service/src/main/java/com/waither/weatherservice/controller/WeatherController.java +++ b/weather-service/src/main/java/com/waither/weatherservice/controller/WeatherController.java @@ -10,6 +10,7 @@ import com.waither.weatherservice.response.ApiResponse; import com.waither.weatherservice.service.WeatherService; +import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -20,12 +21,22 @@ public class WeatherController { private final WeatherService weatherService; + @Operation(summary = "모든 날씨 정보 가져오기 - 프론트, noti-service 사용", + description = "{" + + "\"latitude\": 37.41," + + "\"longitude\": 126.73" + + "}") @GetMapping("/main") public ApiResponse getMainWeather(@ModelAttribute @Valid GetWeatherRequest getWeatherRequest) { return ApiResponse.onSuccess( weatherService.getMainWeather(getWeatherRequest.latitude(), getWeatherRequest.longitude())); } + @Operation(summary = "위도, 경도 -> 지역 변환", + description = "{" + + "\"latitude\": 37.41," + + "\"longitude\": 126.73" + + "}") @GetMapping("/region") public ApiResponse convertGpsToRegionName(@ModelAttribute @Valid GetWeatherRequest getWeatherRequest) { return ApiResponse.onSuccess( diff --git a/weather-service/src/main/java/com/waither/weatherservice/dto/request/GetWeatherRequest.java b/weather-service/src/main/java/com/waither/weatherservice/dto/request/GetWeatherRequest.java index bffdf83e..30ef9e4d 100644 --- a/weather-service/src/main/java/com/waither/weatherservice/dto/request/GetWeatherRequest.java +++ b/weather-service/src/main/java/com/waither/weatherservice/dto/request/GetWeatherRequest.java @@ -2,16 +2,16 @@ import jakarta.validation.constraints.DecimalMax; import jakarta.validation.constraints.DecimalMin; -import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; public record GetWeatherRequest( - @NotBlank(message = "[ERROR] 위도 입력은 필수 입니다.") + @NotNull(message = "[ERROR] 위도 입력은 필수 입니다.") @DecimalMin(value = "33.0", message = "[ERROR] 위도는 33.0도에서 43.0도 사이여야 합니다.") @DecimalMax(value = "43.0", message = "[ERROR] 위도는 33.0도에서 43.0도 사이여야 합니다.") - double latitude, - @NotBlank(message = "[ERROR] 경도 입력은 필수 입니다.") + Double latitude, + @NotNull(message = "[ERROR] 경도 입력은 필수 입니다.") @DecimalMin(value = "124.0", message = "[ERROR] 경도는 124.0도에서 132.0도 사이여야 합니다.") @DecimalMax(value = "132.0", message = "[ERROR] 경도는 124.0도에서 132.0도 사이여야 합니다.") - double longitude + Double longitude ) { } diff --git a/weather-service/src/main/java/com/waither/weatherservice/service/WeatherService.java b/weather-service/src/main/java/com/waither/weatherservice/service/WeatherService.java index f5fd5e6f..2f0c25da 100644 --- a/weather-service/src/main/java/com/waither/weatherservice/service/WeatherService.java +++ b/weather-service/src/main/java/com/waither/weatherservice/service/WeatherService.java @@ -18,7 +18,6 @@ import com.waither.weatherservice.entity.WeatherAdvisory; import com.waither.weatherservice.exception.WeatherExceptionHandler; import com.waither.weatherservice.gps.GpsTransfer; -import com.waither.weatherservice.gps.LatXLngY; import com.waither.weatherservice.kafka.KafkaMessage; import com.waither.weatherservice.kafka.Producer; import com.waither.weatherservice.openapi.ForeCastOpenApiResponse; @@ -160,11 +159,13 @@ public void convertLocation(double latitude, double longitude) throws URISyntaxE } public MainWeatherResponse getMainWeather(double latitude, double longitude) { - LatXLngY latXLngY = GpsTransfer.convertGpsToGrid(latitude, longitude); - LocalDateTime now = LocalDateTime.now(); List region = regionRepository.findRegionByLatAndLong(latitude, longitude); + + if (region.isEmpty()) + throw new WeatherExceptionHandler(WeatherErrorCode.WEATHER_MAIN_ERROR); + String key = region.get(0).getRegionName() + "_" + convertLocalDateTimeToString(now); // 테스트 키 : "서울특별시_20240508_1500"