From 3a21eb7ea1f304a320b93a7aa040622817ce2099 Mon Sep 17 00:00:00 2001 From: Johyunik Date: Sat, 2 Dec 2023 20:24:00 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B6=80=EB=B6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/weatherfit/board/controller/BoardController.java | 2 +- src/main/java/com/weatherfit/board/domain/BoardEntity.java | 2 +- src/main/java/com/weatherfit/board/domain/ImageEntity.java | 7 ++----- src/main/java/com/weatherfit/board/dto/ImageDTO.java | 2 +- src/main/java/com/weatherfit/board/dto/MyLikeDTO.java | 2 +- .../java/com/weatherfit/board/service/BoardService.java | 6 +++--- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/weatherfit/board/controller/BoardController.java b/src/main/java/com/weatherfit/board/controller/BoardController.java index 70346c4..e130fb0 100644 --- a/src/main/java/com/weatherfit/board/controller/BoardController.java +++ b/src/main/java/com/weatherfit/board/controller/BoardController.java @@ -118,7 +118,7 @@ public String insertBoard(@RequestHeader("decodedToken") String nickName, @Reque String imageUrl = imageService.saveImage(image); ImageEntity imageEntity = ImageEntity.builder() - .image_url(imageUrl) + .imageUrl(imageUrl) .boardId(savedBoard) .build(); imageRepository.save(imageEntity); diff --git a/src/main/java/com/weatherfit/board/domain/BoardEntity.java b/src/main/java/com/weatherfit/board/domain/BoardEntity.java index 2d7d755..e5b8f83 100644 --- a/src/main/java/com/weatherfit/board/domain/BoardEntity.java +++ b/src/main/java/com/weatherfit/board/domain/BoardEntity.java @@ -60,7 +60,7 @@ public ImageDTO entityToDTO(ImageEntity imageEntity) { return ImageDTO.builder() .boardId(imageEntity.getBoardId().getBoardId()) .imageId(imageEntity.getImageId()) - .image_url(imageEntity.getImage_url()) + .imageUrl(imageEntity.getImageUrl()) .build(); } } diff --git a/src/main/java/com/weatherfit/board/domain/ImageEntity.java b/src/main/java/com/weatherfit/board/domain/ImageEntity.java index ed07039..854feaf 100644 --- a/src/main/java/com/weatherfit/board/domain/ImageEntity.java +++ b/src/main/java/com/weatherfit/board/domain/ImageEntity.java @@ -24,17 +24,14 @@ public class ImageEntity { private BoardEntity boardId; @Column(name = "image_url", nullable = false) - private String image_url; + private String imageUrl; public ImageDTO entityToDTO(ImageEntity imageEntity) { return ImageDTO.builder() .boardId(imageEntity.getBoardId().getBoardId()) .imageId(imageEntity.getImageId()) - .image_url(imageEntity.getImage_url()) + .imageUrl(imageEntity.getImageUrl()) .build(); } - public String getImageUrl() { // 수정된 부분 - return image_url; - } } diff --git a/src/main/java/com/weatherfit/board/dto/ImageDTO.java b/src/main/java/com/weatherfit/board/dto/ImageDTO.java index e757d40..2af000a 100644 --- a/src/main/java/com/weatherfit/board/dto/ImageDTO.java +++ b/src/main/java/com/weatherfit/board/dto/ImageDTO.java @@ -12,7 +12,7 @@ public class ImageDTO { private int imageId; private int boardId; - private String image_url; + private String imageUrl; } diff --git a/src/main/java/com/weatherfit/board/dto/MyLikeDTO.java b/src/main/java/com/weatherfit/board/dto/MyLikeDTO.java index 6c6c573..4205d8a 100644 --- a/src/main/java/com/weatherfit/board/dto/MyLikeDTO.java +++ b/src/main/java/com/weatherfit/board/dto/MyLikeDTO.java @@ -13,7 +13,7 @@ public class MyLikeDTO { public MyLikeDTO(BoardEntity boardEntity) { this.boardId = boardEntity.getBoardId(); if(!boardEntity.getImages().isEmpty()) { - this.images = String.valueOf(boardEntity.getImages().get(0).getImage_url()); + this.images = String.valueOf(boardEntity.getImages().get(0).getImageUrl()); } } } diff --git a/src/main/java/com/weatherfit/board/service/BoardService.java b/src/main/java/com/weatherfit/board/service/BoardService.java index 59ae85f..00e6697 100644 --- a/src/main/java/com/weatherfit/board/service/BoardService.java +++ b/src/main/java/com/weatherfit/board/service/BoardService.java @@ -171,7 +171,7 @@ public void patchBoard(int boardId, String boardJson, MultipartFile[] images, St String imageUrl = imageService.saveImage(image); ImageEntity imageEntity = ImageEntity.builder() - .image_url(imageUrl) + .imageUrl(imageUrl) .boardId(originalBoard) .build(); imageRepository.save(imageEntity); @@ -181,10 +181,10 @@ public void patchBoard(int boardId, String boardJson, MultipartFile[] images, St // 새로운 이미지 URL과 기존의 이미지 URL을 비교하여 이미지가 수정되었는지 판단합니다. for (ImageEntity originalImage : originalBoard.getImages()) { - boolean isModified = newImages.stream().noneMatch(newImage -> newImage.getImage_url().equals(originalImage.getImage_url())); + boolean isModified = newImages.stream().noneMatch(newImage -> newImage.getImageUrl().equals(originalImage.getImageUrl())); if (isModified) { // 이미지가 수정되었을 경우, 기존의 이미지를 삭제합니다. - imageService.deleteImage(originalImage.getImage_url()); + imageService.deleteImage(originalImage.getImageUrl()); imageRepository.delete(originalImage); } }