Skip to content

Commit

Permalink
Merge pull request Me1tingPot#94 from Me1tingPot/chore/Me1tingPot#90
Browse files Browse the repository at this point in the history
[Chore] 지역 μ’Œν‘œ λ³€ν™˜μ„ μ½”λ“œ 기반으둜 λ™μž‘ν•˜κ²Œ ν•˜λΌ
  • Loading branch information
runasy-koonta authored Jun 7, 2024
2 parents 5be0bce + ae63b1d commit b0aba05
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/main/java/meltingpot/server/area/service/AreaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,6 @@ public AreaResponse getAreaByCoordinate(Double latitude, Double longitude) {
throw new IllegalArgumentException("법정동 정보가 μ—†λŠ” μ’Œν‘œμž…λ‹ˆλ‹€.");
}

List<String> areaNames = Arrays.asList(bArea.region_1depth_name(), bArea.region_2depth_name(), bArea.region_3depth_name(), bArea.region_4depth_name());
Area lastArea = null;
for (String areaName: areaNames) {
if (areaName.isEmpty()) {
continue;
}

Area area;
if (lastArea == null) {
area = areaRepository.findAreaByAreaParentIdIsNullAndAreaName(areaName);
} else {
area = areaRepository.findAreaByAreaParentIdAndAreaName(lastArea.getId(), areaName);
}

if (area == null) {
// λ§Œμ•½ 정보가 μ—†λŠ” 경우 μƒμœ„ 지역을 λ°˜ν™˜ν•œλ‹€
continue;
}
lastArea = area;
}

if (lastArea == null) {
throw new IllegalArgumentException("ν•΄λ‹Ή 지역 정보가 μ—†μŠ΅λ‹ˆλ‹€.");
}

return AreaResponse.of(lastArea);
return AreaResponse.of(areaRepository.findById(bArea.code()).orElseThrow(() -> new IllegalArgumentException("ν•΄λ‹Ή 지역 정보가 μ—†μŠ΅λ‹ˆλ‹€.")));
}
}

0 comments on commit b0aba05

Please sign in to comment.