From dd9cfafdabc6fef7e8ddc405362b8e624f1deea3 Mon Sep 17 00:00:00 2001 From: Beakjiyeon Date: Sun, 7 Apr 2024 04:16:01 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B9=84=EC=A7=80=EB=8B=88=EC=8A=A4?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/board/service/BoardService.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) 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