Skip to content

Commit

Permalink
#39 [Update] 업장 구현 페이징까지 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna-Jin committed Jul 25, 2022
1 parent 4630f13 commit 141d8f4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public List<StoreCardResponseDto> searchStoresByKeyword(
@RequestParam String sido,
@RequestParam String sigungu,
@RequestParam String keyword,
@PageableDefault Pageable pageable,
@AuthenticationPrincipal User user) {

storeService.searchStores(sido, sigungu, keyword);
return null;
return storeService.searchStores(sido, sigungu, keyword, user == null ? null : user.getUsername(), pageable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,16 @@ public Page<Store> findStoreOrderByBookmark(BigDecimal lat,
}

// 주소로 검색, 검색어로 검색
public List<Store> searchStores(String sido, String sigungu, String keyword) {
public List<Store> searchStores(String sido, String sigungu, String keyword, Pageable pageable) {
BooleanExpression matchAddress = QueryDslSearch.matchAddress(sido, sigungu);
BooleanExpression matchKeyword = QueryDslSearch.matchKeyword(keyword);

return queryFactory
.selectFrom(store)
.where(matchAddress,
matchKeyword)
.limit(pageable.getPageSize())
.offset(pageable.getOffset())
.fetch();
}

Expand Down
26 changes: 20 additions & 6 deletions src/main/java/com/mpnp/baechelin/store/service/StoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,26 @@ public Map<String, List<String>> getSigungu(String sido) {
return result;
}

public List<StoreCardResponseDto> searchStores(String sido, String sigungu, String keyword) {
List<Store> storeList = storeQueryRepository.searchStores(sido, sigungu, keyword);
public List<StoreCardResponseDto> searchStores(String sido, String sigungu, String keyword, String socialId, Pageable pageable) {
List<Store> storeList = storeQueryRepository.searchStores(sido, sigungu, keyword, pageable);

// for (Store store : storeList) {
//
// }
return null;
List<StoreCardResponseDto> result = new ArrayList<>();

for (Store store : storeList) {
if (socialId == null) {
result.add(new StoreCardResponseDto(store, "N"));
} else {
String isBookmark = "N";
for (Bookmark bookmark : store.getBookmarkList()) {
if (bookmark.getStoreId().getId() == store.getId()
&& bookmark.getUserId().getSocialId().equals(socialId)) {
isBookmark = "Y";
break;
}
}
result.add(new StoreCardResponseDto(store, isBookmark));
}
}
return result;
}
}

0 comments on commit 141d8f4

Please sign in to comment.