From 18cfbd44ef976d6a191fc65f11d6437ecdee3426 Mon Sep 17 00:00:00 2001 From: jeongyeon0208 Date: Mon, 2 Dec 2024 21:07:39 +0900 Subject: [PATCH] =?UTF-8?q?#229=20Refactor:=20=ED=99=88=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=EC=99=80=EC=9D=B8=20=EB=B0=98=ED=99=98=20=EA=B0=9C=EC=88=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drinkeg/wine/repository/WineRepositoryImpl.java | 2 +- .../com/drinkeg/drinkeg/wine/service/WineServiceImpl.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/drinkeg/drinkeg/wine/repository/WineRepositoryImpl.java b/src/main/java/com/drinkeg/drinkeg/wine/repository/WineRepositoryImpl.java index 4bada09..f50bede 100644 --- a/src/main/java/com/drinkeg/drinkeg/wine/repository/WineRepositoryImpl.java +++ b/src/main/java/com/drinkeg/drinkeg/wine/repository/WineRepositoryImpl.java @@ -120,7 +120,7 @@ public List findRecommendWines(Member member) { .otherwise(0.0)) .desc() ) - .limit(10) + .limit(20) .fetch(); } diff --git a/src/main/java/com/drinkeg/drinkeg/wine/service/WineServiceImpl.java b/src/main/java/com/drinkeg/drinkeg/wine/service/WineServiceImpl.java index 4232000..126da86 100644 --- a/src/main/java/com/drinkeg/drinkeg/wine/service/WineServiceImpl.java +++ b/src/main/java/com/drinkeg/drinkeg/wine/service/WineServiceImpl.java @@ -66,7 +66,14 @@ public HomeResponseDTO getHomeResponse(PrincipalDetail principalDetail) { Member member = memberRepository.findByUsername(principalDetail.getUsername()).orElseThrow( () -> new GeneralException(ErrorStatus.MEMBER_NOT_FOUND)); + // max 20개의 추천 와인을 찾는다. List recommendWines = wineRepository.findRecommendWines(member); + + // 만약 추천 와인의 수가 5개를 넘어간다면, 랜덤으로 5개의 와인만 반환한다. + if (recommendWines.size() > 5) { + Collections.shuffle(recommendWines); + recommendWines = recommendWines.subList(0, 5); + } return HomeResponseDTO.create(member, recommendWines); }