Skip to content

Commit

Permalink
Merge pull request #96 from Mojacknong/fix_88/팜클럽-도움말-수정
Browse files Browse the repository at this point in the history
[fix] 내 팜클럽 조회 시 현재 스텝의 도움말만 뜨도록 변경
  • Loading branch information
Ryeolee authored Aug 19, 2024
2 parents 48a03ec + 7c0e48c commit c093531
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public GetMyFarmClubResponseDto getMyFarmClub(Long farmClubId, Long userId) {
GetMyFarmClubVo farmClubInfo = farmClubRepository.findMyFarmClub(farmClubId, userId);
String veggieInfoId = farmClubInfo.veggieInfoId();
List<StepVo> stepList = veggieInfoHelper.getStepList(veggieInfoId);
String randomTip = getRandomTip(stepList);
String randomTip = getRandomTip(stepList, farmClubInfo.currentStep());
List<GetMissionPostListVo> missionList =
missionPostRepository.getMissionPostStepNumAndImage(farmClubId);

Expand Down Expand Up @@ -167,14 +167,14 @@ public void withdrawFarmClub(Long farmClubId, Long userId, Boolean deleteVeggie)
}
}

private String getRandomTip(List<StepVo> stepList) {
private String getRandomTip(List<StepVo> stepList, int currentStep) {
List<String> 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()));
}

Expand Down

0 comments on commit c093531

Please sign in to comment.