diff --git a/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java b/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java index 243b25a..8187493 100644 --- a/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java +++ b/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java @@ -113,14 +113,13 @@ private Page findStoreOrderByPointNullCase(BooleanBuilder builder, return new PageImpl<>(storeList, pageable, fetchCount); } - //TODO 북마크순 public Page findStoreOrderByBookmark(BigDecimal lat, BigDecimal lng, String category, List facility, Pageable pageable) { - BooleanBuilder builder = locTwoPointAndConditions(lat, lng, category, facility); + if (lat == null || lng == null) return findStoreOrderByBookmarkNullCase(builder, pageable); List storeList = queryFactory.selectFrom(store) .where(builder) .orderBy(store.bookMarkCount.desc()) @@ -132,6 +131,19 @@ public Page findStoreOrderByBookmark(BigDecimal lat, return new PageImpl<>(storeList, pageable, fetchCount); } + public Page findStoreOrderByBookmarkNullCase(BooleanBuilder builder, + Pageable pageable) { + + List storeList = queryFactory.selectFrom(store) + .where(builder) + .orderBy(store.bookMarkCount.desc()) + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) + .fetch(); + int fetchCount = queryFactory.selectFrom(store).where(builder).fetch().size(); + return new PageImpl<>(storeList, pageable, fetchCount); + } + // 주소로 검색, 검색어로 검색 public List searchStores(String sido, String sigungu, String keyword, Pageable pageable) { BooleanExpression matchAddress = QueryDslSearch.matchAddress(sido, sigungu);