From 33cf1adb0d671aa3772472d2f40e0190db57bcf3 Mon Sep 17 00:00:00 2001 From: xhaktmchl Date: Sun, 16 Oct 2022 19:04:29 +0900 Subject: [PATCH] =?UTF-8?q?#9=20feat:=20updateBoard=20API=EC=97=90=20?= =?UTF-8?q?=EC=83=88=EB=A1=9C=EC=9A=B4=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=ED=95=98=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yogit/server/board/dto/request/CreateBoardReq.java | 2 +- .../yogit/server/board/dto/request/PatchBoardReq.java | 6 ++++++ .../yogit/server/board/service/BoardServiceImpl.java | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/yogit/server/board/dto/request/CreateBoardReq.java b/server/src/main/java/com/yogit/server/board/dto/request/CreateBoardReq.java index fbe0712..3cc3a74 100644 --- a/server/src/main/java/com/yogit/server/board/dto/request/CreateBoardReq.java +++ b/server/src/main/java/com/yogit/server/board/dto/request/CreateBoardReq.java @@ -76,7 +76,7 @@ public class CreateBoardReq { @ApiParam(value = "그룹 카테고리 ID", required = true) private Long categoryId; - @ApiModelProperty(example = "예시 구하면 추가 할 예정입니다.") + @ApiModelProperty(example = "\"https://yogit.s3.ap-northeast-2.amazonaws.com/boardimguuid2\"") @ApiParam(value = "게시글 이미지 데이터", required = false) private List images; // 최대 5개 diff --git a/server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java b/server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java index ea4c5d5..fd44e73 100644 --- a/server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java +++ b/server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java @@ -5,10 +5,12 @@ import io.swagger.annotations.ApiParam; import lombok.Data; import lombok.NoArgsConstructor; +import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import java.time.LocalDateTime; +import java.util.List; @Data @NoArgsConstructor @@ -72,4 +74,8 @@ public class PatchBoardReq { @ApiModelProperty(example = "1") @ApiParam(value = "그룹 카테고리 ID", required = false) private Long categoryId; + + @ApiModelProperty(example = "\"https://yogit.s3.ap-northeast-2.amazonaws.com/boardimguuid2\"") + @ApiParam(value = "게시글 이미지 데이터", required = false) + private List images; // 최대 5개 } 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 4036257..d22d9bc 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 @@ -110,6 +110,16 @@ public ApplicationResponse updateBoard(PatchBoardReq dto){ } board.updateBoard(dto, city, category); + + //BoardImages aws s3에 저장 후 리파지토리에도 저장 + if(!dto.getImages().isEmpty()){ + List imageUUids = awsS3Service.uploadImages(dto.getImages()); + for(String i : imageUUids){ + BoardImage boardImage = new BoardImage(board, i); + boardImageRepository.save(boardImage); + imageUrls.add(awsS3Service.makeUrlOfFilename(i)); + } + } BoardRes boardRes = BoardRes.toDto(board, imageUrls); return ApplicationResponse.ok(boardRes); }