Skip to content

Commit

Permalink
Merge pull request #69 from 28th-meetup/feat/sendFcm
Browse files Browse the repository at this point in the history
hotfix: 주소 예외처리 수정
  • Loading branch information
summit45 authored Nov 21, 2023
2 parents a85b17c + d6032d9 commit 7f7b25e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/kusitms/jipbap/user/UserAddressService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.web.client.RestTemplate;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Slf4j
Expand Down Expand Up @@ -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<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public class AddressComponentDto {
@JsonProperty("short_name")
private String shortName;

@JsonProperty("types")
private List<String> types;
}

0 comments on commit 7f7b25e

Please sign in to comment.