Skip to content

Commit

Permalink
#23 [Update] 업장 필터링 null case 추가_2
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 30, 2022
1 parent 45c5550 commit 82013a1
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ private OrderSpecifier<?> orderDistance(BigDecimal nowLat, BigDecimal nowLng) {
return QStore.store.latitude.subtract(nowLat).abs().add(QStore.store.longitude.subtract(nowLng)).abs().asc();
}

//TODO 별점순 - 쿼리 결과로 산출된 리스트의 평균 구하기, 정렬, 페이징
public Page<Store> findStoreOrderByPoint(BigDecimal lat,
BigDecimal lng,
String category,
List<String> facility,
Pageable pageable) {

BooleanBuilder builder = locTwoPointAndConditions(lat, lng, category, facility);
if (lat == null || lng == null) return findStoreOrderByPointNullCase(builder, pageable);
List<Store> storeList = queryFactory
.selectFrom(store)
.where(builder)
Expand All @@ -100,6 +100,19 @@ public Page<Store> findStoreOrderByPoint(BigDecimal lat,
return new PageImpl<>(storeList, pageable, fetchCount);
}

private Page<Store> findStoreOrderByPointNullCase(BooleanBuilder builder,
Pageable pageable) {
List<Store> storeList = queryFactory
.selectFrom(store)
.where(builder)
.orderBy(store.pointAvg.desc())
.limit(pageable.getPageSize())
.offset(pageable.getOffset())
.fetch();
int fetchCount = queryFactory.selectFrom(store).where(builder).fetch().size();
return new PageImpl<>(storeList, pageable, fetchCount);
}

//TODO 북마크순
public Page<Store> findStoreOrderByBookmark(BigDecimal lat,
BigDecimal lng,
Expand Down

0 comments on commit 82013a1

Please sign in to comment.