Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
wellbeing-dough committed Jan 24, 2024
2 parents e5bd7c5 + 36c0919 commit b451028
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/co/kr/jurumarble/drink/service/DrinkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -41,6 +42,7 @@ public class DrinkService {

private static final int FIXED_INDEX_OF_GETTING_HOT_DRINKS = 0;
private static final int NUMBER_OF_HOT_DRINK = 10;
private static final int RANGE_OF_DRINK_MAP = 15;

private final DrinkRepository drinkRepository;
private final EnjoyDrinkRepository enjoyDrinkRepository;
Expand Down Expand Up @@ -105,13 +107,17 @@ public Slice<GetMapInDrinksResponse> getMapInDrinks(Double startX, Double startY
log.info("*******************" + (endY - startY));
double distance = calculateDistanceInKm(startX, startY, endX, endY);
log.info("^^^^^^^^^^^^^^^^^^^^^^^^^^" + distance);
PageRequest pageRequest = PageRequest.of(page, size);
Slice<MapInDrinkData> drinkData = drinkRepository.findDrinksByCoordinate(pageRequest, startX, startY, endX, endY);
return new SliceImpl<>(getGetMapInDrinksResponses(drinkData), drinkData.getPageable(), drinkData.hasNext());
if (distance < RANGE_OF_DRINK_MAP) {
PageRequest pageRequest = PageRequest.of(page, size);
Slice<MapInDrinkData> drinkData = drinkRepository.findDrinksByCoordinate(pageRequest, startX, startY, endX, endY);
return new SliceImpl<>(getGetMapInDrinksResponses(drinkData), drinkData.getPageable(), drinkData.hasNext());
} else {
return new SliceImpl<>(new ArrayList<>());
}
}

public double calculateDistanceInKm(double startX, double startY, double endX, double endY) {
final int R = 6371; // 지구의 반지름
final int R = 6371;

double latDistance = Math.toRadians(endX - startX);
double lonDistance = Math.toRadians(endY - startY);
Expand Down

0 comments on commit b451028

Please sign in to comment.