Skip to content

Commit

Permalink
#9 fix: 보드 카테고리1개별 조회-현재 인원 틀림 에러 해결(스트림->반복문수정)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaktmchl committed Mar 15, 2023
1 parent f0cb780 commit fd549ff
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,22 @@ public ApplicationResponse<GetAllBoardsByCategoryRes> findAllBoardsByCategory(Ge

Page<Board> boards = boardRepository.findAllBoardsByCategory(pageRequest, dto.getCategoryId());
// 보드 res에 이미지uuid -> aws s3 url로 변환
List<GetAllBoardRes> boardsRes = boards.stream()
/*List<GetAllBoardRes> boardsRes = boards.stream()
.filter(board -> !blockedUsers.contains(board.getHost())) // 차단당한 유저의 데이터 제외
.map(board -> GetAllBoardRes.toDto(board, awsS3Service.makeUrlOfFilename(board.getBoardImagesUUids().get(0)), board.getBoardUsers().stream().map(boardUser -> awsS3Service.makeUrlOfFilename(boardUser.getUser().getProfileImg())).collect(Collectors.toList())))
.collect(Collectors.toList());
.collect(Collectors.toList());*/

// 보드 res에 이미지uuid -> aws s3 url로 변환
//TODO: 동작 잘 되는지 확인
List<GetAllBoardRes> boardsRes = new ArrayList<>();
for(Board b:boards){
if(!blockedUsers.contains(b.getHost())){
// 보드 현재 인원
List<BoardUser> participantsOrigin = boardUserRepository.findAllByBoardId(b.getId());
b.changeBoardCurrentMember(participantsOrigin.size());
boardsRes.add(GetAllBoardRes.toDto(b, awsS3Service.makeUrlOfFilename(b.getBoardImagesUUids().get(0)), b.getBoardUsers().stream().map(boardUser -> awsS3Service.makeUrlOfFilename(boardUser.getUser().getProfileImg())).collect(Collectors.toList())));
}
}

return ApplicationResponse.ok(GetAllBoardsByCategoryRes.toDto(boardsRes, boards.getTotalPages()));
}
Expand Down

0 comments on commit fd549ff

Please sign in to comment.