From d6032d9f9eaa001c12deb05a848bc0e58a4b918f Mon Sep 17 00:00:00 2001 From: summit45 Date: Tue, 21 Nov 2023 23:26:09 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20=EC=A3=BC=EC=86=8C=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/kusitms/jipbap/user/UserAddressService.java | 12 ++++++------ .../user/dto/geolocation/AddressComponentDto.java | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/kusitms/jipbap/user/UserAddressService.java b/src/main/java/com/kusitms/jipbap/user/UserAddressService.java index 0ab702f..b7afca1 100644 --- a/src/main/java/com/kusitms/jipbap/user/UserAddressService.java +++ b/src/main/java/com/kusitms/jipbap/user/UserAddressService.java @@ -15,6 +15,7 @@ import org.springframework.web.client.RestTemplate; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; @Slf4j @@ -106,22 +107,21 @@ private PostalAddressDto findPostalAddress(GeocodingAddressDto geocodingAddressD try { String formattedAddress = geocodingAddressDto.getFormattedAddress(); // 실제 데이터베이스에 저장할 주소 - Double lat = geocodingAddressDto.getGeometry().getLocation().getLat(); - Double lng = geocodingAddressDto.getGeometry().getLocation().getLng(); - String countryName = null; String postalCode = null; + for (AddressComponentDto addressComponent : geocodingAddressDto.getAddressComponentList()) { List types = addressComponent.getTypes(); + if (types != null && types.contains("country")) { countryName = addressComponent.getLongName(); } if (types != null && types.contains("postal_code")) { postalCode = addressComponent.getLongName(); } - else{ - throw new PostalCodeNotFoundException("우편번호를 찾을 수 없습니다. 주소를 다시 입력해주세요."); - } + } + if (postalCode == null || postalCode.isEmpty()){ + throw new PostalCodeNotFoundException("우편번호를 찾을 수 없습니다. 주소를 다시 입력해주세요."); } return new PostalAddressDto(formattedAddress, postalCode); } catch (NullPointerException e) { diff --git a/src/main/java/com/kusitms/jipbap/user/dto/geolocation/AddressComponentDto.java b/src/main/java/com/kusitms/jipbap/user/dto/geolocation/AddressComponentDto.java index 4fbb7ec..9c176d5 100644 --- a/src/main/java/com/kusitms/jipbap/user/dto/geolocation/AddressComponentDto.java +++ b/src/main/java/com/kusitms/jipbap/user/dto/geolocation/AddressComponentDto.java @@ -15,5 +15,6 @@ public class AddressComponentDto { @JsonProperty("short_name") private String shortName; + @JsonProperty("types") private List types; } \ No newline at end of file