diff --git a/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java b/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java index dcd7b84..1e89072 100644 --- a/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java +++ b/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java @@ -7,10 +7,17 @@ import java.util.List; -@Getter @Setter +@Getter +@Setter @NoArgsConstructor -@AllArgsConstructor public class StorePagedResponseDto { private boolean hasNextPage; + private long totalCount; private List cards; + + public StorePagedResponseDto(boolean hasNextPage, List cards, long totalCount) { + this.hasNextPage = hasNextPage; + this.cards = cards; + this.totalCount = totalCount; + } } \ No newline at end of file diff --git a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java index 66158ea..ef4ec0a 100644 --- a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java +++ b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java @@ -15,6 +15,7 @@ import com.mpnp.baechelin.user.domain.User; import com.mpnp.baechelin.user.repository.UserRepository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -58,13 +59,6 @@ public StorePagedResponseDto getStoreInRange(BigDecimal latStart, BigDecimal lat return getStoreCardPagedResponseDto(targetUser, betweenLngLat); } - public StorePagedResponseDto getStoreInTwoPointsRange(BigDecimal latStart, BigDecimal latEnd, BigDecimal lngStart, BigDecimal lngEnd, String category, List facility, Pageable pageable, String socialId) { -// public List getStoreInRange(BigDecimal latStart, BigDecimal latEnd, BigDecimal lngStart, BigDecimal lngEnd, String category, List facility, Pageable pageable, String socialId) { - User targetUser = socialId == null ? null : userRepository.findBySocialId(socialId); - Page betweenSquare = storeQueryRepository.findBetweenTwoPoint(latStart, latEnd, lngStart, lngEnd, category, facility, pageable); - // store 가져와서 dto 매핑 - return getStoreCardPagedResponseDto(targetUser, betweenSquare); - } /** * @param lat 위도 @@ -126,17 +120,11 @@ public StorePagedResponseDto getStoreInRangeHighBookmark(BigDecimal lat, BigDeci */ private StorePagedResponseDto getStoreCardPagedResponseDto(User targetUser, Page resultStoreList) { List mappingResult = new ArrayList<>(); - if (targetUser == null) { - for (Store store : resultStoreList) { - mappingResult.add(new StoreCardResponseDto(store, "N")); - } - } else { - for (Store store : resultStoreList) { - boolean isBookmark = bookmarkRepository.existsByStoreIdAndUserId(store, targetUser); - mappingResult.add(new StoreCardResponseDto(store, isBookmark ? "Y" : "N")); - } + for (Store store : resultStoreList) { + boolean isBookmark = bookmarkRepository.existsByStoreIdAndUserId(store, targetUser); + mappingResult.add(new StoreCardResponseDto(store, isBookmark ? "Y" : "N")); } - return new StorePagedResponseDto(resultStoreList.hasNext(), mappingResult); + return new StorePagedResponseDto(resultStoreList.hasNext(), mappingResult, resultStoreList.getTotalElements()); }