Skip to content

Commit

Permalink
fix: 위치정보 조회 수정 #33
Browse files Browse the repository at this point in the history
  • Loading branch information
yongseok-dev committed May 23, 2023
1 parent 08fdcd7 commit f522602
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public GeoLocationResponseDTO getLocation(
if (ipAddress == null || ipAddress.isEmpty()) {
ipAddress = request.getRemoteAddr();
}
System.out.println(ipAddress);
return geoLocationService.getGeoLocation(ipAddress);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@ public GeoLocationResponseDTO getGeoLocation(String ipAddress) {
Optional<GeoLocation> optionalGeoLocation = geoLocationRepository.findRecentRecordByIpAddress(
ipAddress, startTime);

GeoLocation geoLocation;
if (optionalGeoLocation.isPresent()) {
geoLocation = optionalGeoLocation.get();
} else {
try {
GeoLocation geoLocation = new GeoLocation();
try {
if (optionalGeoLocation.isPresent()) {
geoLocation = optionalGeoLocation.get();
} else {
geoLocation = callNcloudApiGeolocation(ipAddress);
geoLocationRepository.save(geoLocation);
} catch (JsonProcessingException e) {
geoLocation = new GeoLocation();
throw new RuntimeException(e);
}
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
} finally {
if ("서울특별시".equals(geoLocation.getR1())) {
return GeoLocationResponseDTO.OkFromGeoLocation(geoLocation);
}
return GeoLocationResponseDTO.Ok();
}

if ("서울특별시".equals(geoLocation.getR1())) {
return GeoLocationResponseDTO.OkFromGeoLocation(geoLocation);
}

return GeoLocationResponseDTO.Ok();
}

private GeoLocation callNcloudApiGeolocation(String ipAddress) throws JsonProcessingException {
Expand Down

0 comments on commit f522602

Please sign in to comment.