From 7c0e48c93156b22aa8db01493f25f78b8287f192 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Mon, 19 Aug 2024 21:56:16 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EB=82=B4=20=ED=8C=9C=ED=81=B4=EB=9F=BD?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EC=8A=A4=ED=85=9D=EC=9D=98=20=EB=8F=84=EC=9B=80=EB=A7=90?= =?UTF-8?q?=EB=A7=8C=20=EB=9C=A8=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/farmclub/service/FarmClubService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java index 858f787..f0d5e61 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java @@ -128,7 +128,7 @@ public GetMyFarmClubResponseDto getMyFarmClub(Long farmClubId, Long userId) { GetMyFarmClubVo farmClubInfo = farmClubRepository.findMyFarmClub(farmClubId, userId); String veggieInfoId = farmClubInfo.veggieInfoId(); List stepList = veggieInfoHelper.getStepList(veggieInfoId); - String randomTip = getRandomTip(stepList); + String randomTip = getRandomTip(stepList, farmClubInfo.currentStep()); List missionList = missionPostRepository.getMissionPostStepNumAndImage(farmClubId); @@ -167,14 +167,14 @@ public void withdrawFarmClub(Long farmClubId, Long userId, Boolean deleteVeggie) } } - private String getRandomTip(List stepList) { + private String getRandomTip(List stepList, int currentStep) { List tips = new ArrayList<>(); - stepList.forEach(step -> tips.addAll(step.tips())); - - if (tips.isEmpty()) { - return "아직 도움말이 없습니다."; + for (StepVo step : stepList) { + if (step.num() == currentStep) { + tips = step.tips(); + break; + } } - return tips.get((int) (Math.random() * tips.size())); }