diff --git a/server/src/main/java/com/yogit/server/board/controller/ClipBoardController.java b/server/src/main/java/com/yogit/server/board/controller/ClipBoardController.java index a1238ca..0d133c6 100644 --- a/server/src/main/java/com/yogit/server/board/controller/ClipBoardController.java +++ b/server/src/main/java/com/yogit/server/board/controller/ClipBoardController.java @@ -54,20 +54,20 @@ public ApplicationResponse 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> 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> findAllClipBoards(@RequestBody @Validated GetAllClipBoardsReq getAllClipBoardsReq){ +// return clipBoardService.findAllClipBoards(getAllClipBoardsReq); +// } /** diff --git a/server/src/main/java/com/yogit/server/board/dto/response/clipboard/GetClipBoardRes.java b/server/src/main/java/com/yogit/server/board/dto/response/clipboard/GetClipBoardRes.java index 4385ec3..cc1a0ad 100644 --- a/server/src/main/java/com/yogit/server/board/dto/response/clipboard/GetClipBoardRes.java +++ b/server/src/main/java/com/yogit/server/board/dto/response/clipboard/GetClipBoardRes.java @@ -24,6 +24,14 @@ public class GetClipBoardRes { @ApiParam(value = "유저 ID") private Long userId; + @ApiModelProperty(example = "Park jun") + @ApiParam(value = "유저 이름") + private String userName; + + @ApiModelProperty(example = "추가 예정") + @ApiParam(value = "유저 프로필 이미지 url") + private String profileImgUrl; + @ApiModelProperty(example = "1") @ApiParam(value = "Board ID") private Long boardId; @@ -56,10 +64,12 @@ public class GetClipBoardRes { @ApiParam(value = "마지막 업데이트 시각") private String updatedAt; - public static GetClipBoardRes toDto(ClipBoard clipBoard, List commentResList){ + public static GetClipBoardRes toDto(ClipBoard clipBoard, List commentResList, String profileImgUrl){ return GetClipBoardRes.builder() .clipBoardId(clipBoard.getId()) .userId(clipBoard.getUser().getId()) + .userName(clipBoard.getUser().getName()) + .profileImgUrl(profileImgUrl) .boardId(clipBoard.getBoard().getId()) .title(clipBoard.getTitle()) .content(clipBoard.getContent()) @@ -72,9 +82,11 @@ public static GetClipBoardRes toDto(ClipBoard clipBoard, List commen } @Builder - public GetClipBoardRes(Long clipBoardId, Long userId, Long boardId, String title, String content, List commentResList, Integer commentCnt, BaseStatus status, String createdAt, String updatedAt) { + public GetClipBoardRes(Long clipBoardId, Long userId, String userName, String profileImgUrl, Long boardId, String title, String content, List commentResList, Integer commentCnt, BaseStatus status, String createdAt, String updatedAt) { this.clipBoardId = clipBoardId; this.userId = userId; + this.userName = userName; + this.profileImgUrl = profileImgUrl; this.boardId = boardId; this.title = title; this.content = content; diff --git a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardService.java b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardService.java index 4d3c003..a87d36f 100644 --- a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardService.java +++ b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardService.java @@ -13,7 +13,7 @@ public interface ClipBoardService { ApplicationResponse findClipBoard(GetClipBoardReq getClipBoardReq); - ApplicationResponse> findAllClipBoards(GetAllClipBoardsReq getAllClipBoardsReq); +// ApplicationResponse> findAllClipBoards(GetAllClipBoardsReq getAllClipBoardsReq); ApplicationResponse deleteClipBoard(DeleteClipBoardReq deleteClipBoardReq); diff --git a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java index 8dc4431..3f2f6f7 100644 --- a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java @@ -15,6 +15,7 @@ import com.yogit.server.board.repository.ClipBoardRepository; import com.yogit.server.board.repository.CommentRepository; import com.yogit.server.global.dto.ApplicationResponse; +import com.yogit.server.s3.AwsS3Service; import com.yogit.server.user.entity.User; import com.yogit.server.user.exception.NotFoundUserException; import com.yogit.server.user.repository.UserRepository; @@ -34,6 +35,7 @@ public class ClipBoardServiceImpl implements ClipBoardService{ private final UserRepository userRepository; private final BoardRepository boardRepository; private final CommentRepository commentRepository; + private final AwsS3Service awsS3Service; @Transactional(readOnly = false) @Override @@ -70,31 +72,33 @@ public ApplicationResponse findClipBoard(GetClipBoardReq dto){ .map(comment -> CommentRes.toDto(comment)) .collect(Collectors.toList()); + String profileImgUrl = awsS3Service.makeUrlOfFilename(user.getProfileImg());// 유저 프로필 사진 multipart -> url 로 변환 + // 코멘트 추가 - GetClipBoardRes getClipBoardRes = GetClipBoardRes.toDto(clipBoard, comments); + GetClipBoardRes getClipBoardRes = GetClipBoardRes.toDto(clipBoard, comments, profileImgUrl); return ApplicationResponse.ok(getClipBoardRes); } - @Transactional(readOnly = true) - @Override - public ApplicationResponse> findAllClipBoards(GetAllClipBoardsReq dto){ - - User user = userRepository.findById(dto.getUserId()) - .orElseThrow(() -> new NotFoundUserException()); - - Board board = boardRepository.findBoardById(dto.getBoardId()) - .orElseThrow(() -> new NotFoundBoardException()); - - // 클립보드 res안에 해당하는 코멘트 리스트까지 조회 및 포함 - List 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> findAllClipBoards(GetAllClipBoardsReq dto){ +// +// User user = userRepository.findById(dto.getUserId()) +// .orElseThrow(() -> new NotFoundUserException()); +// +// Board board = boardRepository.findBoardById(dto.getBoardId()) +// .orElseThrow(() -> new NotFoundBoardException()); +// +// // 클립보드 res안에 해당하는 코멘트 리스트까지 조회 및 포함 +// List 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 = false)