Skip to content

Commit

Permalink
#23 [Update] 북마크순 정렬에 페이징 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 21, 2022
1 parent 8a15012 commit ed811d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public StorePagedResponseDto getStoreInRangeHighPoint(@RequestParam(required = f
}

@GetMapping("/bookmark")
public List<StoreCardResponseDto> getStoreInRangeHighBookmark(@RequestParam(required = false) BigDecimal lat,
public StorePagedResponseDto getStoreInRangeHighBookmark(@RequestParam(required = false) BigDecimal lat,
@RequestParam(required = false) BigDecimal lng,
@RequestParam(required = false) String category,
@RequestParam(required = false) List<String> facility,
@RequestParam int limit,
@PageableDefault Pageable pageable,
@AuthenticationPrincipal User user) {
return storeService.getStoreInRangeHighBookmark(lat, lng, category, facility, limit, user == null ? null : user.getUsername());
return storeService.getStoreInRangeHighBookmark(lat, lng, category, facility, pageable, user == null ? null : user.getUsername());
}

@ApiOperation(value = "업장 상세정보를 조회하는 메소드")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,22 @@ public Page<Store> findStoreOrderByPoint(BigDecimal lat,
}

//TODO 북마크순
public List<Store> findStoreOrderByBookmark(BigDecimal lat,
public Page<Store> findStoreOrderByBookmark(BigDecimal lat,
BigDecimal lng,
String category,
List<String> facility,
int limit) {
Pageable pageable) {

BooleanBuilder builder = locTwoPointAndConditions(lat, lng, category, facility);

return queryFactory.selectFrom(store)
List<Store> storeList = queryFactory.selectFrom(store)
.where(builder)
.orderBy(store.bookMarkCount.desc())
.limit(limit)
.limit(pageable.getPageSize())
.offset(pageable.getOffset())
.fetch();
int fetchCount = queryFactory.selectFrom(store).where(builder).fetch().size();
return new PageImpl<>(storeList, pageable, fetchCount);
}

}
13 changes: 6 additions & 7 deletions src/main/java/com/mpnp/baechelin/store/service/StoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,23 @@ public StorePagedResponseDto getStoreInRangeMap(BigDecimal lat, BigDecimal lng,
public StorePagedResponseDto getStoreInRangeHighPoint(BigDecimal lat, BigDecimal lng, String
category, List<String> facility, Pageable pageable, String socialId) {
User targetUser = socialId == null ? null : userRepository.findBySocialId(socialId);
Page<Store> resultList = storeQueryRepository.findStoreOrderByPoint(lat, lng, category, facility, pageable);
return getStoreCardPagedResponseDto(targetUser, resultList);
Page<Store> pagedResultList = storeQueryRepository.findStoreOrderByPoint(lat, lng, category, facility, pageable);
return getStoreCardPagedResponseDto(targetUser, pagedResultList);
}

/**
* @param lat 위도
* @param lng 경도
* @param category 업장 카테고리
* @param facility 배리어 프리 태그
* @param limit 표시할 업장의 개수
* @param socialId 유저 소셜 아이디
* @return 위도, 경도, 카테고리, 배리어 프리 태그에 해당하는 북마크가 높은 업장 리스트를 설정한 숫자만큼 리턴
*/
public List<StoreCardResponseDto> getStoreInRangeHighBookmark(BigDecimal lat, BigDecimal lng, String
category, List<String> facility, int limit, String socialId) {
public StorePagedResponseDto getStoreInRangeHighBookmark(BigDecimal lat, BigDecimal lng, String
category, List<String> facility, Pageable pageable, String socialId) {
User targetUser = socialId == null ? null : userRepository.findBySocialId(socialId);
List<Store> highBookmarkResultList = storeQueryRepository.findStoreOrderByBookmark(lat, lng, category, facility, limit);
return getStoreCardResponseDtos(targetUser, highBookmarkResultList);
Page<Store> highBookmarkResultList = storeQueryRepository.findStoreOrderByBookmark(lat, lng, category, facility, pageable);
return getStoreCardPagedResponseDto(targetUser, highBookmarkResultList);
}

/**
Expand Down

0 comments on commit ed811d0

Please sign in to comment.