-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#23 [Add] 리스트 조회 - 카테고리, 위/경도, 배리어프리 태그로 필터링
- Loading branch information
Showing
5 changed files
with
130 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/mpnp/baechelin/review/repository/ReviewQueryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.mpnp.baechelin.review.repository; | ||
|
||
import com.mpnp.baechelin.review.domain.QReview; | ||
import com.mpnp.baechelin.review.domain.Review; | ||
import com.mpnp.baechelin.store.domain.Store; | ||
import com.querydsl.core.BooleanBuilder; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import javax.transaction.Transactional; | ||
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
import static com.mpnp.baechelin.review.domain.QReview.review1; | ||
import static com.mpnp.baechelin.store.domain.QStore.store; | ||
|
||
@Repository | ||
@Transactional | ||
public class ReviewQueryRepository extends QuerydslRepositorySupport { | ||
private final JPAQueryFactory queryFactory; | ||
private final BooleanBuilder builder = new BooleanBuilder(); | ||
|
||
public ReviewQueryRepository(JPAQueryFactory queryFactory) { | ||
super(Review.class); | ||
this.queryFactory = queryFactory; | ||
} | ||
|
||
public List<Review> findRecentReviews(BigDecimal latStart, | ||
BigDecimal latEnd, | ||
BigDecimal lngStart, | ||
BigDecimal lngEnd, | ||
int limit) { | ||
builder.and(store.latitude.goe(latStart)); | ||
builder.and(store.latitude.loe(latEnd)); | ||
builder.and(store.longitude.goe(lngStart)); | ||
builder.and(store.longitude.loe(lngEnd)); | ||
// 위도 경도에 해당하는 가게를 찾음 -> 해당 댓글을 다 가져옴 -> 내림차순 정렬 -> limit | ||
return queryFactory.selectFrom(review1) | ||
.innerJoin(review1.storeId, store) | ||
.where(review1.storeId | ||
.in(queryFactory.select(store).from(store).where(builder))) | ||
.limit(limit) | ||
.fetch(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters