diff --git a/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java b/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java index 6170203..2cd2d28 100644 --- a/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java +++ b/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java @@ -97,9 +97,9 @@ public List 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); } } \ No newline at end of file diff --git a/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java b/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java index 719dcd0..20cb8bd 100644 --- a/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java +++ b/src/main/java/com/mpnp/baechelin/store/repository/StoreQueryRepository.java @@ -111,7 +111,7 @@ public Page findStoreOrderByBookmark(BigDecimal lat, } // 주소로 검색, 검색어로 검색 - public List searchStores(String sido, String sigungu, String keyword) { + public List searchStores(String sido, String sigungu, String keyword, Pageable pageable) { BooleanExpression matchAddress = QueryDslSearch.matchAddress(sido, sigungu); BooleanExpression matchKeyword = QueryDslSearch.matchKeyword(keyword); @@ -119,6 +119,8 @@ public List searchStores(String sido, String sigungu, String keyword) { .selectFrom(store) .where(matchAddress, matchKeyword) + .limit(pageable.getPageSize()) + .offset(pageable.getOffset()) .fetch(); } diff --git a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java index d4ecea8..532796b 100644 --- a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java +++ b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java @@ -203,12 +203,26 @@ public Map> getSigungu(String sido) { return result; } - public List searchStores(String sido, String sigungu, String keyword) { - List storeList = storeQueryRepository.searchStores(sido, sigungu, keyword); + public List searchStores(String sido, String sigungu, String keyword, String socialId, Pageable pageable) { + List storeList = storeQueryRepository.searchStores(sido, sigungu, keyword, pageable); -// for (Store store : storeList) { -// -// } - return null; + List 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; } } \ No newline at end of file