diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java index 69a979ac5..12104ddb2 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardDetailsRetrievalService.java @@ -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 emojiInfos = getBoardEmojiCountResponseDtoList(boardId, currentMemberInfo.getMemberId()); - return BoardDetailsResponseDto.toDto(board, currentMemberInfo, isOwner, emojiInfos); + return BoardDetailsResponseDto.toDto(board, memberInfo, isOwner, emojiInfos); } @Transactional(readOnly = true) diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java index 9c9db20d3..063e8ad38 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardRetrievalService.java @@ -26,9 +26,9 @@ public class BoardRetrievalService implements RetrieveBoardUseCase { @Transactional @Override public PagedResponseDto retrieveBoards(Pageable pageable) { - MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo(); Page boards = retrieveBoardPort.findAll(pageable); - return new PagedResponseDto<>(boards.map(board -> mapToBoardListResponseDto(board, currentMemberInfo))); + return new PagedResponseDto<>(boards.map(board -> + mapToBoardListResponseDto(board, getMemberDetailedInfoByBoard(board)))); } @Override @@ -36,6 +36,10 @@ 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()); diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java index a3b5b9664..927f86765 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/BoardsByCategoryRetrievalService.java @@ -26,11 +26,14 @@ public class BoardsByCategoryRetrievalService implements RetrieveBoardsByCategor @Transactional @Override public PagedResponseDto retrieveBoardsByCategory(BoardCategory category, Pageable pageable) { - MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo(); Page 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()); + } } diff --git a/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java b/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java index ee6660c97..f3658a45e 100644 --- a/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java +++ b/src/main/java/page/clab/api/domain/community/board/application/service/DeletedBoardsRetrievalService.java @@ -26,9 +26,13 @@ public class DeletedBoardsRetrievalService implements RetrieveDeletedBoardsUseCa @Transactional(readOnly = true) @Override public PagedResponseDto retrieveDeletedBoards(Pageable pageable) { - MemberDetailedInfoDto currentMemberInfo = externalRetrieveMemberUseCase.getCurrentMemberDetailedInfo(); Page 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