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())); }