Skip to content

Commit

Permalink
fix(BoardRetrievalService): currentMemberInfo를 게시글 작성자의 memberInfo로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
SongJaeHoonn committed Jul 22, 2024
1 parent 683cf42 commit 5de9576
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public class BoardDetailsRetrievalService implements RetrieveBoardDetailsUseCase
public BoardDetailsResponseDto retrieveBoardDetails(Long boardId) {
MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo();
Board board = retrieveBoardPort.findByIdOrThrow(boardId);
MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(board.getMemberId());
boolean isOwner = board.isOwner(currentMemberInfo.getMemberId());
List<BoardEmojiCountResponseDto> emojiInfos = getBoardEmojiCountResponseDtoList(boardId, currentMemberInfo.getMemberId());
return BoardDetailsResponseDto.toDto(board, currentMemberInfo, isOwner, emojiInfos);
return BoardDetailsResponseDto.toDto(board, memberInfo, isOwner, emojiInfos);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ public class BoardRetrievalService implements RetrieveBoardUseCase {
@Transactional
@Override
public PagedResponseDto<BoardListResponseDto> retrieveBoards(Pageable pageable) {
MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo();
Page<Board> boards = retrieveBoardPort.findAll(pageable);
return new PagedResponseDto<>(boards.map(board -> mapToBoardListResponseDto(board, currentMemberInfo)));
return new PagedResponseDto<>(boards.map(board ->
mapToBoardListResponseDto(board, getMemberDetailedInfoByBoard(board))));
}

@Override
public Board findByIdOrThrow(Long boardId) {
return retrieveBoardPort.findByIdOrThrow(boardId);
}

private MemberDetailedInfoDto getMemberDetailedInfoByBoard(Board board) {
return externalRetrieveMemberUseCase.getMemberDetailedInfoById(board.getMemberId());
}

@NotNull
private BoardListResponseDto mapToBoardListResponseDto(Board board, MemberDetailedInfoDto memberInfo) {
Long commentCount = externalRetrieveCommentUseCase.countByBoardId(board.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ public class BoardsByCategoryRetrievalService implements RetrieveBoardsByCategor
@Transactional
@Override
public PagedResponseDto<BoardCategoryResponseDto> retrieveBoardsByCategory(BoardCategory category, Pageable pageable) {
MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo();
Page<Board> boards = retrieveBoardPort.findAllByCategory(category, pageable);
return new PagedResponseDto<>(boards.map(board -> {
long commentCount = externalRetrieveCommentUseCase.countByBoardId(board.getId());
return BoardCategoryResponseDto.toDto(board, currentMemberInfo, commentCount);
return BoardCategoryResponseDto.toDto(board, getMemberDetailedInfoByBoard(board), commentCount);
}));
}

private MemberDetailedInfoDto getMemberDetailedInfoByBoard(Board board) {
return externalRetrieveMemberUseCase.getMemberDetailedInfoById(board.getMemberId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ public class DeletedBoardsRetrievalService implements RetrieveDeletedBoardsUseCa
@Transactional(readOnly = true)
@Override
public PagedResponseDto<BoardListResponseDto> retrieveDeletedBoards(Pageable pageable) {
MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo();
Page<Board> boards = retrieveBoardPort.findAllByIsDeletedTrue(pageable);
return new PagedResponseDto<>(boards.map(board -> mapToBoardListResponseDto(board, currentMemberInfo)));
return new PagedResponseDto<>(boards.map(board ->
mapToBoardListResponseDto(board, getMemberDetailedInfoByBoard(board))));
}

private MemberDetailedInfoDto getMemberDetailedInfoByBoard(Board board) {
return externalRetrieveMemberUseCase.getMemberDetailedInfoById(board.getMemberId());
}

@NotNull
Expand Down

0 comments on commit 5de9576

Please sign in to comment.