From 7981c5a04c5909a329419c5f422d4c94b5164058 Mon Sep 17 00:00:00 2001 From: KEISS <86196038+ImKEISS@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:12:15 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20=EB=A6=AC=EB=B7=B0=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EC=8B=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8D=98=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/appcenter/BJJ/domain/image/Image.java | 6 ++++-- .../appcenter/BJJ/domain/review/service/ReviewService.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/appcenter/BJJ/domain/image/Image.java b/src/main/java/com/appcenter/BJJ/domain/image/Image.java index 8b3ce57..9582956 100644 --- a/src/main/java/com/appcenter/BJJ/domain/image/Image.java +++ b/src/main/java/com/appcenter/BJJ/domain/image/Image.java @@ -25,8 +25,10 @@ public class Image { private String name; + // 이미지 확장자 private String type; + // 이미지 최종 경로 이름 (review, cafeteria..) private String path; @ManyToOne(fetch = FetchType.LAZY) @@ -79,8 +81,8 @@ public static Image of(MultipartFile file, Review review, String folderPath) thr .build(); } - public boolean removeImageFromPath() { - File file = new File(path); + public boolean removeImageFromPath(String folderPath) { + File file = new File(folderPath, name); return file.delete(); } diff --git a/src/main/java/com/appcenter/BJJ/domain/review/service/ReviewService.java b/src/main/java/com/appcenter/BJJ/domain/review/service/ReviewService.java index eb55186..15a33a4 100644 --- a/src/main/java/com/appcenter/BJJ/domain/review/service/ReviewService.java +++ b/src/main/java/com/appcenter/BJJ/domain/review/service/ReviewService.java @@ -141,7 +141,7 @@ public Long delete(Long reviewId) { Review review = optionalReview.get(); review.getImages().forEach(image -> { - boolean result = image.removeImageFromPath(); + boolean result = image.removeImageFromPath(REVIEW_IMG_DIR); if (!result) { log.info("이미지 {} 삭제에 실패했습니다.", image.getName());