From cabfd5e7ea1b7acb4ca9669d778548344d71976c Mon Sep 17 00:00:00 2001 From: jeongyun1206 <67818407+jeongyun1206@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:36:22 +0900 Subject: [PATCH] =?UTF-8?q?#322=20reafctor:=20=EC=99=80=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EA=B8=B0=EB=8A=A5=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=95=20=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drinkeg/domain/wine/controller/WineController.java | 5 +++-- .../drinkeg/domain/wine/repository/WineRepositoryCustom.java | 3 ++- .../drinkeg/domain/wine/repository/WineRepositoryImpl.java | 5 ++--- .../com/drinkeg/drinkeg/domain/wine/service/WineService.java | 3 ++- .../drinkeg/drinkeg/domain/wine/service/WineServiceImpl.java | 5 +++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/drinkeg/drinkeg/domain/wine/controller/WineController.java b/src/main/java/com/drinkeg/drinkeg/domain/wine/controller/WineController.java index bbc5d369..0d806836 100644 --- a/src/main/java/com/drinkeg/drinkeg/domain/wine/controller/WineController.java +++ b/src/main/java/com/drinkeg/drinkeg/domain/wine/controller/WineController.java @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @@ -30,9 +31,9 @@ public class WineController { // todo: 페이징 구현하기 @GetMapping @Operation(summary = "와인 검색", description = "와인 이름 또는 영어 이름으로 검색하여 와인의 기본 정보를 조회한다.") - public ApiResponse> searchWine(@RequestParam(defaultValue = "") String searchName) { + public ApiResponse> searchWine(@RequestParam(defaultValue = "") String searchName, Pageable pageable) { - List winePreviewResponses = wineService.searchWinesByName(searchName); + List winePreviewResponses = wineService.searchWinesByName(searchName, pageable); return ApiResponse.onSuccess(winePreviewResponses); } diff --git a/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryCustom.java b/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryCustom.java index a07eed1b..e6db7878 100644 --- a/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryCustom.java +++ b/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryCustom.java @@ -2,6 +2,7 @@ import com.drinkeg.drinkeg.domain.wine.domain.Wine; +import org.springframework.data.domain.Pageable; import java.util.List; @@ -10,5 +11,5 @@ public interface WineRepositoryCustom { List findMostLikedWines(); - List searchByName(String name); + List searchByName(String name, Pageable pageable); } diff --git a/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryImpl.java b/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryImpl.java index 033b8834..2f2e0e75 100644 --- a/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryImpl.java +++ b/src/main/java/com/drinkeg/drinkeg/domain/wine/repository/WineRepositoryImpl.java @@ -6,13 +6,12 @@ import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; import java.util.List; -import static com.drinkeg.drinkeg.domain.member.domain.QMember.member; -import static com.drinkeg.drinkeg.domain.tastingNote.domain.QTastingNote.tastingNote; import static com.drinkeg.drinkeg.domain.wine.domain.QWine.wine; import static com.drinkeg.drinkeg.domain.wineWishlist.domain.QWineWishlist.wineWishlist; @@ -33,7 +32,7 @@ public List findMostLikedWines() { } @Override - public List searchByName(String name) { + public List searchByName(String name, Pageable pageable) { return queryFactory.selectFrom(wine) .where( wine.name.containsIgnoreCase(name) diff --git a/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineService.java b/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineService.java index dd186d9d..fb08e613 100644 --- a/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineService.java +++ b/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineService.java @@ -6,13 +6,14 @@ import com.drinkeg.drinkeg.domain.wine.dto.response.WineWithThreeReviewsResponse; import com.drinkeg.drinkeg.domain.wine.dto.response.WineReviewResponse; import com.opencsv.exceptions.CsvException; +import org.springframework.data.domain.Pageable; import java.io.IOException; import java.util.List; public interface WineService { - public List searchWinesByName(String searchName); + public List searchWinesByName(String searchName, Pageable pageable); public void updateWineNoteStatics(Long wineId); diff --git a/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineServiceImpl.java b/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineServiceImpl.java index af8ab5da..44cf1fc2 100644 --- a/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineServiceImpl.java +++ b/src/main/java/com/drinkeg/drinkeg/domain/wine/service/WineServiceImpl.java @@ -23,6 +23,7 @@ import com.opencsv.CSVWriterBuilder; import com.opencsv.exceptions.CsvException; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -46,8 +47,8 @@ public class WineServiceImpl implements WineService { private final StorageService storageService; @Override - public List searchWinesByName(String searchName) { - List searchWines = wineRepository.searchByName(searchName); + public List searchWinesByName(String searchName, Pageable pageable) { + List searchWines = wineRepository.searchByName(searchName, pageable); return searchWines.stream() .map(WinePreviewResponse::of)