Skip to content

Commit

Permalink
#23 [Update] 별점순 정렬 구현중
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 12, 2022
1 parent 14ac83f commit 22c4fd3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public List<StoreResponseDto> getStoreInRangeHighPoint(@RequestParam(required =
@RequestParam(required = false) String category,
@RequestParam(required = false) List<String> facility,
@PageableDefault Pageable pageable) {
List<Store> betweenLngLat = storeQueryRepository.findBetweenLngLat(latStart, latEnd, lngStart, lngEnd, category, facility, pageable);
List<Store> betweenLngLat = storeQueryRepository.findStoreOrderByPoint(latStart, latEnd, lngStart, lngEnd, category, facility, pageable);
return betweenLngLat.parallelStream().map(storeService::storeToResDto).collect(Collectors.toList());// 순서보장
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.mpnp.baechelin.store.repository;

import com.mpnp.baechelin.config.QuerydslConfiguration;
import com.mpnp.baechelin.review.repository.ReviewQueryRepository;
import com.mpnp.baechelin.store.domain.QStore;
import com.mpnp.baechelin.store.domain.Store;
import com.mpnp.baechelin.tag.domain.QTag;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.Tuple;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.StringPath;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand All @@ -19,9 +16,11 @@
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import static com.mpnp.baechelin.review.domain.QReview.review1;
import static com.mpnp.baechelin.store.domain.QStore.store;
import static com.querydsl.jpa.JPAExpressions.avg;
import static com.querydsl.jpa.JPAExpressions.select;

@Repository
@Transactional
Expand Down Expand Up @@ -59,16 +58,26 @@ public List<Store> findStoreOrderByPoint(BigDecimal latStart,
BigDecimal lngEnd,
String category,
List<String> facility,
int limit) {
Pageable pageable) {


locAndConditions(latStart, latEnd, lngStart, lngEnd, category, facility);

return queryFactory.selectFrom(store)
.where(builder)
.orderBy(store.pointAvg.desc())
.limit(limit)
.limit(pageable.getPageSize())
.offset(pageable.getOffset())
.fetch();

// return queryFactory.selectFrom(store)
// .leftJoin(store, review1.storeId)
// .on(store.id.eq(review1.storeId.id))
// .where(builder)
// .orderBy(review1.point.avg().desc())
// .limit(pageable.getPageSize())
// .offset(pageable.getOffset())
// .fetch();
}

//TODO 북마크순
Expand Down
Empty file.

0 comments on commit 22c4fd3

Please sign in to comment.