Skip to content

Commit

Permalink
fix: 비지니스로직수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Beakjiyeon committed Apr 6, 2024
1 parent 206be8d commit dd9cfaf
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,15 @@ public FindBoardListResponse getMyBoards(Long memberId) {

public List<BoardResponseDto> getRandomBoards(Long memberId) {
List<BoardResponseDto> result = getTodayBoardByMemberId(memberId);
if (result.size() < 3) {
List<Board> 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<Board> 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<toSave; i++) {
ReadBoard entity = ReadBoard.createReadBoard(member, boards.get(i));
result.add(BoardResponseDto.from(boards.get(i)));
readBoardRepository.save(entity);
Expand Down

0 comments on commit dd9cfaf

Please sign in to comment.