Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

커뮤니티 게시글 작성자가 로그인 된 본인으로 응답되는 버그 해결 #423

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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