Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public class PlaceCourseService {
private final PlaceCourseRepository placeCourseRepository;

public CompletableFuture<PlaceInfoPreviewResponse> 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 {
Expand All @@ -83,7 +87,8 @@ public CompletableFuture<PlaceInfoPreviewResponse> getPlacesByLocation(String se
Optional<Place> 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);
}
Expand Down Expand Up @@ -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<String, String> getPlaceInfo(Long poiId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
}

Expand Down