diff --git a/server/src/main/java/com/yogit/server/board/controller/BoardController.java b/server/src/main/java/com/yogit/server/board/controller/BoardController.java index b0f8231..037b871 100644 --- a/server/src/main/java/com/yogit/server/board/controller/BoardController.java +++ b/server/src/main/java/com/yogit/server/board/controller/BoardController.java @@ -5,6 +5,7 @@ import com.yogit.server.board.dto.request.boardimage.DeleteBoardImageReq; import com.yogit.server.board.dto.request.boardimage.DeleteBoardImageRes; import com.yogit.server.board.dto.response.BoardRes; +import com.yogit.server.board.dto.response.DeleteBoardRes; import com.yogit.server.board.dto.response.GetAllBoardRes; import com.yogit.server.board.dto.response.GetBoardRes; import com.yogit.server.board.service.BoardService; @@ -57,7 +58,7 @@ public class BoardController { @ApiResponse(code = 4000 , message = "서버 오류입니다.") }) @PostMapping("") - public ApplicationResponse registerBoard(@ModelAttribute @Validated CreateBoardReq createBoardReq){ + public ApplicationResponse registerBoard(@ModelAttribute @Validated CreateBoardReq createBoardReq){ return boardService.createBoard(createBoardReq); } @@ -112,7 +113,7 @@ public ApplicationResponse updateBoard(@ModelAttribute @Validated P @ApiResponse(code = 4000 , message = "서버 오류입니다.") }) @PatchMapping("/status") - public ApplicationResponse deleteBoard(@RequestBody @Validated DeleteBoardReq deleteBoardReq){ + public ApplicationResponse deleteBoard(@RequestBody @Validated DeleteBoardReq deleteBoardReq){ return boardService.deleteBoard(deleteBoardReq); } diff --git a/server/src/main/java/com/yogit/server/board/dto/response/DeleteBoardRes.java b/server/src/main/java/com/yogit/server/board/dto/response/DeleteBoardRes.java new file mode 100644 index 0000000..27c6dea --- /dev/null +++ b/server/src/main/java/com/yogit/server/board/dto/response/DeleteBoardRes.java @@ -0,0 +1,27 @@ +package com.yogit.server.board.dto.response; + +import com.yogit.server.board.entity.Board; +import com.yogit.server.config.domain.BaseStatus; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class DeleteBoardRes { + + @ApiModelProperty(example = "ACTIVE", value = "객체 상태") + private BaseStatus status; + + @Builder + public DeleteBoardRes(BaseStatus status) { + this.status = status; + } + + public static DeleteBoardRes toDto(Board board){ + return DeleteBoardRes.builder() + .status(board.getStatus()) + .build(); + } +} diff --git a/server/src/main/java/com/yogit/server/board/service/BoardService.java b/server/src/main/java/com/yogit/server/board/service/BoardService.java index a13ac38..b007488 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardService.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardService.java @@ -4,6 +4,7 @@ import com.yogit.server.board.dto.request.boardimage.DeleteBoardImageReq; import com.yogit.server.board.dto.request.boardimage.DeleteBoardImageRes; import com.yogit.server.board.dto.response.BoardRes; +import com.yogit.server.board.dto.response.DeleteBoardRes; import com.yogit.server.board.dto.response.GetAllBoardRes; import com.yogit.server.board.dto.response.GetBoardRes; import com.yogit.server.global.dto.ApplicationResponse; @@ -12,11 +13,11 @@ public interface BoardService { - ApplicationResponse createBoard(CreateBoardReq createBoardReq); + ApplicationResponse createBoard(CreateBoardReq createBoardReq); ApplicationResponse updateBoard(PatchBoardReq patchBoardReq); - ApplicationResponse deleteBoard(DeleteBoardReq deleteBoardReq); + ApplicationResponse deleteBoard(DeleteBoardReq deleteBoardReq); ApplicationResponse>> findAllBoards(GetAllBoardsReq getAllBoardsReq); diff --git a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java index 7a91268..c56e766 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java @@ -5,6 +5,7 @@ import com.yogit.server.board.dto.request.boardimage.DeleteBoardImageReq; import com.yogit.server.board.dto.request.boardimage.DeleteBoardImageRes; import com.yogit.server.board.dto.response.BoardRes; +import com.yogit.server.board.dto.response.DeleteBoardRes; import com.yogit.server.board.dto.response.GetAllBoardRes; import com.yogit.server.board.dto.response.GetBoardRes; import com.yogit.server.board.entity.*; @@ -58,7 +59,7 @@ public class BoardServiceImpl implements BoardService{ @Transactional(readOnly = false) @Override - public ApplicationResponse createBoard(CreateBoardReq dto){ + public ApplicationResponse createBoard(CreateBoardReq dto){ userService.validateRefreshToken(dto.getHostId(), dto.getRefreshToken()); @@ -105,8 +106,17 @@ public ApplicationResponse createBoard(CreateBoardReq dto){ } } - BoardRes boardRes = BoardRes.toDto(savedBoard, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(host.getProfileImg())); // resDto 벼환 - return ApplicationResponse.create("요청에 성공하였습니다.", boardRes); + List participants = board.getBoardUsers().stream() + .map(boardUser -> boardUser.getUser()) + .collect(Collectors.toList()); + + List participantsImageUUIds = board.getBoardUsers().stream() + .map(boardUser -> boardUser.getUser().getProfileImg()) + .collect(Collectors.toList()); + + GetBoardRes res = GetBoardRes.toDto(savedBoard, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(board.getHost().getProfileImg()), participants, awsS3Service.makeUrlsOfFilenames(participantsImageUUIds), host); + //BoardRes boardRes = BoardRes.toDto(savedBoard, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(host.getProfileImg())); // resDto 벼환 + return ApplicationResponse.create("요청에 성공하였습니다.", res); } @@ -175,7 +185,7 @@ public ApplicationResponse updateBoard(PatchBoardReq dto){ @Transactional(readOnly = false) @Override - public ApplicationResponse deleteBoard(DeleteBoardReq dto){ + public ApplicationResponse deleteBoard(DeleteBoardReq dto){ userService.validateRefreshToken(dto.getHostId(), dto.getRefreshToken()); @@ -190,7 +200,7 @@ public ApplicationResponse deleteBoard(DeleteBoardReq dto){ } board.deleteBoard(); - BoardRes boardRes = BoardRes.toDto(board, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(user.getProfileImg())); + DeleteBoardRes boardRes = DeleteBoardRes.toDto(board); return ApplicationResponse.ok(boardRes); }