Skip to content

Commit

Permalink
Merge branch 'main' into feat/user-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
shinhn committed Jan 26, 2023
2 parents 6c969d5 + c5bcca8 commit 30f3a61
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,7 +58,7 @@ public class BoardController {
@ApiResponse(code = 4000 , message = "서버 오류입니다.")
})
@PostMapping("")
public ApplicationResponse<BoardRes> registerBoard(@ModelAttribute @Validated CreateBoardReq createBoardReq){
public ApplicationResponse<GetBoardRes> registerBoard(@ModelAttribute @Validated CreateBoardReq createBoardReq){
return boardService.createBoard(createBoardReq);
}

Expand Down Expand Up @@ -112,7 +113,7 @@ public ApplicationResponse<GetBoardRes> updateBoard(@ModelAttribute @Validated P
@ApiResponse(code = 4000 , message = "서버 오류입니다.")
})
@PatchMapping("/status")
public ApplicationResponse<BoardRes> deleteBoard(@RequestBody @Validated DeleteBoardReq deleteBoardReq){
public ApplicationResponse<DeleteBoardRes> deleteBoard(@RequestBody @Validated DeleteBoardReq deleteBoardReq){
return boardService.deleteBoard(deleteBoardReq);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,11 +13,11 @@

public interface BoardService {

ApplicationResponse<BoardRes> createBoard(CreateBoardReq createBoardReq);
ApplicationResponse<GetBoardRes> createBoard(CreateBoardReq createBoardReq);

ApplicationResponse<GetBoardRes> updateBoard(PatchBoardReq patchBoardReq);

ApplicationResponse<BoardRes> deleteBoard(DeleteBoardReq deleteBoardReq);
ApplicationResponse<DeleteBoardRes> deleteBoard(DeleteBoardReq deleteBoardReq);

ApplicationResponse<List<List<GetAllBoardRes>>> findAllBoards(GetAllBoardsReq getAllBoardsReq);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class BoardServiceImpl implements BoardService{

@Transactional(readOnly = false)
@Override
public ApplicationResponse<BoardRes> createBoard(CreateBoardReq dto){
public ApplicationResponse<GetBoardRes> createBoard(CreateBoardReq dto){

userService.validateRefreshToken(dto.getHostId(), dto.getRefreshToken());

Expand Down Expand Up @@ -105,8 +106,17 @@ public ApplicationResponse<BoardRes> createBoard(CreateBoardReq dto){
}
}

BoardRes boardRes = BoardRes.toDto(savedBoard, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(host.getProfileImg())); // resDto 벼환
return ApplicationResponse.create("요청에 성공하였습니다.", boardRes);
List<User> participants = board.getBoardUsers().stream()
.map(boardUser -> boardUser.getUser())
.collect(Collectors.toList());

List<String> 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);
}


Expand Down Expand Up @@ -175,7 +185,7 @@ public ApplicationResponse<GetBoardRes> updateBoard(PatchBoardReq dto){

@Transactional(readOnly = false)
@Override
public ApplicationResponse<BoardRes> deleteBoard(DeleteBoardReq dto){
public ApplicationResponse<DeleteBoardRes> deleteBoard(DeleteBoardReq dto){

userService.validateRefreshToken(dto.getHostId(), dto.getRefreshToken());

Expand All @@ -190,7 +200,7 @@ public ApplicationResponse<BoardRes> 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);
}

Expand Down

0 comments on commit 30f3a61

Please sign in to comment.