Skip to content

Commit

Permalink
#23 feat:클립보드 전체조회(findAllClipBoards) Res에 userName, profileImgUrl 필드…
Browse files Browse the repository at this point in the history
… 값추가
  • Loading branch information
xhaktmchl committed Nov 8, 2022
1 parent bb7e349 commit 2fc56fd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ public ApplicationResponse<GetClipBoardRes> findClipBoard(@RequestBody @Validate
}


// /**
// * 클립보드 전체 조회
// * @author 토마스
// */
// @ApiOperation(value = "클립보드 전체 조회", notes = "Board ID로 클립보드 전체 조회 요청.")
// @ApiResponses({
// @ApiResponse(code= 201, message = "요청에 성공하였습니다."),
// @ApiResponse(code= 404, message = "존재하지 않는 유저입니다."),
// @ApiResponse(code = 4000 , message = "서버 오류입니다.")
// })
// @PostMapping("/get/all")
// public ApplicationResponse<List<GetClipBoardRes>> findAllClipBoards(@RequestBody @Validated GetAllClipBoardsReq getAllClipBoardsReq){
// return clipBoardService.findAllClipBoards(getAllClipBoardsReq);
// }
/**
* 클립보드 전체 조회
* @author 토마스
*/
@ApiOperation(value = "클립보드 전체 조회", notes = "Board ID로 클립보드 전체 조회 요청.")
@ApiResponses({
@ApiResponse(code= 201, message = "요청에 성공하였습니다."),
@ApiResponse(code= 404, message = "존재하지 않는 유저입니다."),
@ApiResponse(code = 4000 , message = "서버 오류입니다.")
})
@PostMapping("/get/all")
public ApplicationResponse<List<GetClipBoardRes>> findAllClipBoards(@RequestBody @Validated GetAllClipBoardsReq getAllClipBoardsReq){
return clipBoardService.findAllClipBoards(getAllClipBoardsReq);
}


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface ClipBoardService {

ApplicationResponse<GetClipBoardRes> findClipBoard(GetClipBoardReq getClipBoardReq);

// ApplicationResponse<List<GetClipBoardRes>> findAllClipBoards(GetAllClipBoardsReq getAllClipBoardsReq);
ApplicationResponse<List<GetClipBoardRes>> findAllClipBoards(GetAllClipBoardsReq getAllClipBoardsReq);

ApplicationResponse<ClipBoardRes> deleteClipBoard(DeleteClipBoardReq deleteClipBoardReq);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,27 @@ public ApplicationResponse<GetClipBoardRes> findClipBoard(GetClipBoardReq dto){
}


// @Transactional(readOnly = true)
// @Override
// public ApplicationResponse<List<GetClipBoardRes>> findAllClipBoards(GetAllClipBoardsReq dto){
//
// User user = userRepository.findById(dto.getUserId())
// .orElseThrow(() -> new NotFoundUserException());
//
// Board board = boardRepository.findBoardById(dto.getBoardId())
// .orElseThrow(() -> new NotFoundBoardException());
//
// // 클립보드 res안에 해당하는 코멘트 리스트까지 조회 및 포함
// List<GetClipBoardRes> getClipBoardResList = clipBoardRepository.findAllByBoardId(dto.getBoardId()).stream()
// .map(clipBoard -> GetClipBoardRes.toDto(clipBoard, commentRepository.findAllCommentsByClipBoardId(clipBoard.getId()).stream()
// .map(comment -> CommentRes.toDto(comment))
// .collect(Collectors.toList())))
// .collect(Collectors.toList());
//
// return ApplicationResponse.ok(getClipBoardResList);
// }
@Transactional(readOnly = true)
@Override
public ApplicationResponse<List<GetClipBoardRes>> findAllClipBoards(GetAllClipBoardsReq dto){

User user = userRepository.findById(dto.getUserId())
.orElseThrow(() -> new NotFoundUserException());

Board board = boardRepository.findBoardById(dto.getBoardId())
.orElseThrow(() -> new NotFoundBoardException());

// 클립보드 res안에 해당하는 코멘트 리스트까지 조회 및 포함
// 유저 profileImgUrl 또한 img uuid -> s3 url로 변환
List<GetClipBoardRes> getClipBoardResList = clipBoardRepository.findAllByBoardId(dto.getBoardId()).stream()
.map(clipBoard -> GetClipBoardRes.toDto(clipBoard, commentRepository.findAllCommentsByClipBoardId(clipBoard.getId()).stream()
.map(comment -> CommentRes.toDto(comment))
.collect(Collectors.toList()),
awsS3Service.makeUrlOfFilename(clipBoard.getUser().getProfileImg())))
.collect(Collectors.toList());

return ApplicationResponse.ok(getClipBoardResList);
}


@Transactional(readOnly = false)
Expand Down

0 comments on commit 2fc56fd

Please sign in to comment.