diff --git a/src/main/java/com/unit/daybook/domain/board/service/BoardService.java b/src/main/java/com/unit/daybook/domain/board/service/BoardService.java index 52007ae..2b9aaa6 100644 --- a/src/main/java/com/unit/daybook/domain/board/service/BoardService.java +++ b/src/main/java/com/unit/daybook/domain/board/service/BoardService.java @@ -72,27 +72,15 @@ public FindBoardListResponse getMyBoards(Long memberId) { public List getRandomBoards(Long memberId) { List result = getTodayBoardByMemberId(memberId); - if (result.size() < 3) { - List boards = getCurrentBoards(memberId); - // read-board 에도 적재 - Member member = memberRepository - .findById(memberId) - .orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); - readBoardRepository.save(ReadBoard.createReadBoard(member, boards.get(0))); - readBoardRepository.save(ReadBoard.createReadBoard(member, boards.get(1))); - readBoardRepository.save(ReadBoard.createReadBoard(member, boards.get(2))); - result = boards.stream() - .map(BoardResponseDto::from) - .toList(); + if (result.size() == 3) { + return result; } result = new ArrayList<>(); List boards = getCurrentBoards(memberId); // read-board 에도 적재 - Member member = memberRepository - .findById(memberId) - .orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); + Member member = memberRepository.findById(memberId).orElseThrow(() -> new RuntimeException(memberId + "not found")); int toSave = 3 - result.size(); - for (int i = 0 ; i < toSave; i++) { + for (int i =0 ; i