From 2c6679cbf5776321d9888cee2778ebfce07f3a7f Mon Sep 17 00:00:00 2001 From: StoneCAU Date: Thu, 20 Feb 2025 16:23:32 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9E=A5=EC=86=8C=20=EA=B2=80=EC=83=89?= =?UTF-8?q?=20response=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../placeCourse/dto/response/PlaceInfoPreview.java | 2 ++ .../mapping/placeCourse/service/PlaceCourseService.java | 9 +++++++-- .../catchy/domain/place/converter/PlaceConverter.java | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/umc/catchy/domain/mapping/placeCourse/dto/response/PlaceInfoPreview.java b/src/main/java/umc/catchy/domain/mapping/placeCourse/dto/response/PlaceInfoPreview.java index cd946c73..46a7a22c 100644 --- a/src/main/java/umc/catchy/domain/mapping/placeCourse/dto/response/PlaceInfoPreview.java +++ b/src/main/java/umc/catchy/domain/mapping/placeCourse/dto/response/PlaceInfoPreview.java @@ -19,6 +19,8 @@ public class PlaceInfoPreview { private String roadAddress; private String activeTime; private Double rating; + private Double placeLatitude; + private Double placeLongitude; private Long reviewCount; private boolean isLiked; } diff --git a/src/main/java/umc/catchy/domain/mapping/placeCourse/service/PlaceCourseService.java b/src/main/java/umc/catchy/domain/mapping/placeCourse/service/PlaceCourseService.java index 2ff0aea1..8b67546b 100644 --- a/src/main/java/umc/catchy/domain/mapping/placeCourse/service/PlaceCourseService.java +++ b/src/main/java/umc/catchy/domain/mapping/placeCourse/service/PlaceCourseService.java @@ -64,6 +64,10 @@ public class PlaceCourseService { private final PlaceCourseRepository placeCourseRepository; public CompletableFuture getPlacesByLocation(String searchKeyword, Double latitude, Double longitude, Integer page) { + Long memberId = SecurityUtil.getCurrentMemberId(); + Member member = memberRepository.findById(memberId) + .orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_FOUND)); + return CompletableFuture.supplyAsync(() -> getSearchResponse(searchKeyword, latitude, longitude, page)) .thenApply(response -> { try { @@ -83,7 +87,8 @@ public CompletableFuture getPlacesByLocation(String se Optional place = placeRepository.findByPoiId(poiId); if (place.isPresent()) { Long reviewCount = placeReviewRepository.countByPlaceId(place.get().getId()); - return PlaceConverter.toPlaceInfoPreview(place.get(), reviewCount); + Boolean isLiked = placeLikeRepository.findByPlaceAndMember(place.get(), member).isPresent(); + return PlaceConverter.toPlaceInfoPreview(place.get(), reviewCount, isLiked); } else { return createPlace(poiId); } @@ -219,7 +224,7 @@ private PlaceInfoPreview createPlace(Long poiId) { placeRepository.save(place); - return PlaceConverter.toPlaceInfoPreview(place, 0L); + return PlaceConverter.toPlaceInfoPreview(place, 0L, false); } private Map getPlaceInfo(Long poiId) { diff --git a/src/main/java/umc/catchy/domain/place/converter/PlaceConverter.java b/src/main/java/umc/catchy/domain/place/converter/PlaceConverter.java index 823e1e97..cfbe92b2 100644 --- a/src/main/java/umc/catchy/domain/place/converter/PlaceConverter.java +++ b/src/main/java/umc/catchy/domain/place/converter/PlaceConverter.java @@ -28,7 +28,7 @@ public static CourseInfoResponse.getPlaceInfoOfCourseDTO toPlaceInfoOfCourseDTO( .build(); } - public static PlaceInfoPreview toPlaceInfoPreview(Place place, Long reviewCount) { + public static PlaceInfoPreview toPlaceInfoPreview(Place place, Long reviewCount, Boolean isLiked) { String categoryName = null; Double rating = 0.0; @@ -49,6 +49,8 @@ public static PlaceInfoPreview toPlaceInfoPreview(Place place, Long reviewCount) .activeTime(place.getActiveTime()) .rating(rating) .reviewCount(reviewCount) + .placeLatitude(place.getLatitude()) + .placeLongitude(place.getLongitude()) .build(); }