Skip to content

Commit 6983912

Browse files
authored
πŸ›fix: 날씨 API μ˜ˆμ™Έ 처리 μˆ˜μ • (#90)
2 parents 54a0026 + ef936f8 commit 6983912

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

β€Žsrc/main/java/org/withtime/be/withtimebe/domain/weather/dto/request/WeatherReqDTO.javaβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import jakarta.validation.constraints.NotNull;
44
import jakarta.validation.constraints.Positive;
5+
import org.withtime.be.withtimebe.global.error.code.WeatherErrorCode;
6+
import org.withtime.be.withtimebe.global.error.exception.WeatherException;
57

68
import java.time.LocalDate;
79

@@ -26,8 +28,7 @@ public static GetWeeklyRecommendation of(Long regionId, LocalDate startDate) {
2628
LocalDate maxDate = now.plusDays(7);
2729

2830
if (startDate.isBefore(minDate) || startDate.isAfter(maxDate)) {
29-
throw new IllegalArgumentException(
30-
"쑰회 κ°€λŠ₯ν•œ μ‹œμž‘ λ‚ μ§œ λ²”μœ„λ₯Ό λ²—μ–΄λ‚¬μŠ΅λ‹ˆλ‹€. (7일 μ „ ~ 7일 ν›„)");
31+
throw new WeatherException(WeatherErrorCode.INVALID_DATE_RANGE);
3132
}
3233
}
3334

@@ -57,8 +58,7 @@ public static GetWeeklyPrecipitation of(Long regionId, LocalDate startDate) {
5758
LocalDate maxDate = now.plusDays(10);
5859

5960
if (startDate.isBefore(minDate) || startDate.isAfter(maxDate)) {
60-
throw new IllegalArgumentException(
61-
"쑰회 κ°€λŠ₯ν•œ μ‹œμž‘ λ‚ μ§œ λ²”μœ„λ₯Ό λ²—μ–΄λ‚¬μŠ΅λ‹ˆλ‹€. (7일 μ „ ~ 10일 ν›„)");
61+
throw new WeatherException(WeatherErrorCode.INVALID_DATE_RANGE);
6262
}
6363
}
6464

β€Žsrc/main/java/org/withtime/be/withtimebe/domain/weather/service/command/WeatherTriggerServiceImpl.javaβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.withtime.be.withtimebe.domain.weather.data.utils.WeatherDataHelper;
1010
import org.withtime.be.withtimebe.domain.weather.dto.request.WeatherSyncReqDTO;
1111
import org.withtime.be.withtimebe.domain.weather.dto.response.WeatherSyncResDTO;
12+
import org.withtime.be.withtimebe.global.error.code.WeatherErrorCode;
13+
import org.withtime.be.withtimebe.global.error.exception.WeatherException;
1214

1315
import java.time.LocalDate;
1416
import java.time.LocalDateTime;
@@ -109,7 +111,7 @@ private Object executeJob(WeatherSyncReqDTO.ManualTrigger request) {
109111
.build();
110112
}
111113

112-
default -> throw new IllegalArgumentException("μ§€μ›ν•˜μ§€ μ•ŠλŠ” μž‘μ—… νƒ€μž…: " + request.jobType());
114+
default -> throw new WeatherException(WeatherErrorCode.UNSUPPORTED_TASK_TYPE);
113115
};
114116
}
115117
}

β€Žsrc/main/java/org/withtime/be/withtimebe/global/error/code/WeatherErrorCode.javaβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ public enum WeatherErrorCode implements BaseErrorCode {
2121
REGION_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, "WEATHER400_0", "이미 μ‘΄μž¬ν•˜λŠ” μ§€μ—­μž…λ‹ˆλ‹€."),
2222
WEATHER_TEMPLATE_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, "WEATHER400_1", "이미 μ‘΄μž¬ν•˜λŠ” 날씨 ν…œν”Œλ¦Ώμž…λ‹ˆλ‹€."),
2323
INVALID_COORDINATES(HttpStatus.BAD_REQUEST, "WEATHER400_2", "μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ μ’Œν‘œμž…λ‹ˆλ‹€."),
24-
INVALID_DATE_RANGE(HttpStatus.BAD_REQUEST, "WEATHER400_3", "μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ λ‚ μ§œ λ²”μœ„μž…λ‹ˆλ‹€."),
24+
INVALID_DATE_RANGE(HttpStatus.BAD_REQUEST, "WEATHER400_3", "μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ λ‚ μ§œ λ²”μœ„μž…λ‹ˆλ‹€. 쑰회 κ°€λŠ₯ν•œ μ‹œμž‘ λ‚ μ§œ λ²”μœ„λ₯Ό λ²—μ–΄λ‚¬μŠ΅λ‹ˆλ‹€. (7일 μ „ ~ 7일 ν›„)"),
2525
INVALID_WEATHER_DATA(HttpStatus.BAD_REQUEST, "WEATHER400_4", "μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ 날씨 λ°μ΄ν„°μž…λ‹ˆλ‹€."),
2626
INVALID_REGION_CODE(HttpStatus.BAD_REQUEST, "WEATHER400_5", "μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ μ§€μ—­μ½”λ“œμž…λ‹ˆλ‹€."),
2727
INVALID_ENUM_VALUE(HttpStatus.BAD_REQUEST, "WEATHER400_6", "μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ μ—΄κ±°ν˜• κ°’μž…λ‹ˆλ‹€."),
28+
UNSUPPORTED_TASK_TYPE(HttpStatus.BAD_REQUEST, "WEATHER400_7", "μ§€μ›ν•˜μ§€ μ•ŠλŠ” μž‘μ—… νƒ€μž…μž…λ‹ˆλ‹€."),
2829

2930
// ==== κΆŒν•œ/인증 μ—λŸ¬ (403) ====
3031
ACCESS_DENIED(HttpStatus.FORBIDDEN, "WEATHER403_0", "μ ‘κ·Ό κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€."),

0 commit comments

Comments
Β (0)