Skip to content

Commit

Permalink
[feat] 홈 배너 조회 api 구현
Browse files Browse the repository at this point in the history
[feat] 홈 배너 조회 api 구현
  • Loading branch information
bo-ram-bo-ram authored Jul 12, 2024
2 parents a35ef7e + 18c3d1f commit 63e1575
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ public ApiResponseDto getMoimQuestionList(@PathVariable Long moimId) {
return ApiResponseDto.success(SuccessCode.MOIM_QUESTION_LIST_GET_SUCCESS,
moimQueryService.getMoimQuestionList(moimId));
}

@GetMapping("/v1/moim/banner")
private ApiResponseDto getMoimBanner() {
return ApiResponseDto.success(SuccessCode.MOIM_BANNER_GET_SUCCESS,
moimQueryService.getMoimBanner());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,14 @@ public QuestionInfo getMoimQuestionList(final Long moimId) {
Moim moim = moimRepository.findMoimByIdOrThrow(moimId);
return moim.getQuestionList();
}

public Long getMoimBanner() {
List<Long> moimIdList = moimRepository.findAll()
.stream()
.map(Moim::getId)
.toList();

int randomIndex = random.nextInt(moimIdList.size());
return moimIdList.get(randomIndex);
}
}

0 comments on commit 63e1575

Please sign in to comment.