Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿš€ [Deploy] - ์‹ค์‹œ๊ฐ„ ๊ธฐ์ƒ์ •๋ณด ์กฐํšŒ ์ฝ”๋“œ ๋ณ€๊ฒฝ (#47) #48

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/ice/spot/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public enum ErrorCode {

//500
INTERNAL_SERVER_ERROR(50000, HttpStatus.INTERNAL_SERVER_ERROR, "์„œ๋ฒ„ ๋‚ด๋ถ€ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค"),
SERVICE_ACCESS_DENIED_ERROR(50001, HttpStatus.INTERNAL_SERVER_ERROR, "์ผ์‹œ์ ์œผ๋กœ ๊ธฐ์ƒ์ •๋ณด๋ฅผ ๋ฐ›์ง€ ๋ชปํ•˜์˜€์Šต๋‹ˆ๋‹ค.")
;

private final Integer code;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/ice/spot/service/RestTemplateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import ice.spot.dto.district.response.dust.DustResultResponse;
import ice.spot.dto.district.response.weather.WeatherItemResponse;
import ice.spot.dto.district.response.weather.WeatherResultResponse;
import ice.spot.exception.CommonException;
import ice.spot.exception.ErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpEntity;
Expand Down Expand Up @@ -91,10 +93,11 @@ public TemperatureResponse getRealtimeWeather(String nx, String ny) {
String HH = parsedLocalDateTime.format(DateTimeFormatter.ofPattern("HH")) + "00";

try {
final String secretKey = "zNmiod%2F0aq5%2F06rrd8wHCmHhake9Vvj%2BY%2BX%2BsnrK7AU9uvTvg2qtAfZrjm9Gu1navvJG3%2B9sSN6MfriPi0rlLA%3D%3D";
URI uri = UriComponentsBuilder
.fromUriString("http://apis.data.go.kr")
.path("/1360000/VilageFcstInfoService_2.0/getUltraSrtNcst")
.queryParam("ServiceKey", "zNmiod/0aq5/06rrd8wHCmHhake9Vvj+Y+X+snrK7AU9uvTvg2qtAfZrjm9Gu1navvJG3+9sSN6MfriPi0rlLA==")
.queryParam("ServiceKey", secretKey)
.queryParam("pageNo", "1")
.queryParam("numOfRows", "10")
.queryParam("dataType", "JSON")
Expand All @@ -103,7 +106,7 @@ public TemperatureResponse getRealtimeWeather(String nx, String ny) {
.queryParam("nx", nx)
.queryParam("ny", ny)
.encode()
.build()
.build(true)
.toUri();
WeatherResultResponse weatherResultResponse = restTemplate.exchange(uri, HttpMethod.GET, entity, WeatherResultResponse.class).getBody();

Expand All @@ -126,10 +129,7 @@ public TemperatureResponse getRealtimeWeather(String nx, String ny) {

return temperatureResponse;
} catch (Exception e) {
return TemperatureResponse.builder()
.temperature(14.0)
.humidity(79.0)
.build();
throw new CommonException(ErrorCode.SERVICE_ACCESS_DENIED_ERROR);
}
}
}
Loading