From e43d4dcd109defc86b34c525470b725415debf91 Mon Sep 17 00:00:00 2001 From: Donghun Won Date: Mon, 7 Oct 2024 16:14:41 +0900 Subject: [PATCH] =?UTF-8?q?Fix(#216)=20:=20=EC=9D=BC=EA=B8=B0=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=ED=95=98=EB=A3=A8=20=EC=A7=80=EB=82=98?= =?UTF-8?q?=EB=A9=B4=20=EC=82=AD=EC=A0=9C=EB=90=98=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=20(#224)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix : 유저, 일기 이미지 자동삭제 되지 않게 수정 * Fix : 일기 내 이미지 url 쉼표로 구분하여 영구화하도록 수정 --- .../solitour/diary/service/DiaryService.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/solitour_backend/solitour/diary/service/DiaryService.java b/src/main/java/solitour_backend/solitour/diary/service/DiaryService.java index 78c9775..7c90983 100644 --- a/src/main/java/solitour_backend/solitour/diary/service/DiaryService.java +++ b/src/main/java/solitour_backend/solitour/diary/service/DiaryService.java @@ -94,7 +94,8 @@ public void updateDiary(Long userId, Long diaryId, DiaryUpdateRequest request) { } private void updateDiary(Long diaryId, DiaryUpdateRequest request) { - Diary diary = diaryRepository.findById(diaryId).orElseThrow(() -> new DiaryNotExistsException("해당 일기가 존재하지 않습니다.")); + Diary diary = diaryRepository.findById(diaryId) + .orElseThrow(() -> new DiaryNotExistsException("해당 일기가 존재하지 않습니다.")); deleteDiaryImage(request); diary.getDiaryDayContent().clear(); diary.updateDiary(request); @@ -103,7 +104,7 @@ private void updateDiary(Long diaryId, DiaryUpdateRequest request) { private void saveDiaryDayContent(Diary savedDiary, DiaryCreateRequest request) { for (DiaryDayRequest dayRequest : request.getDiaryDayRequests()) { - s3Uploader.markImagePermanent(dayRequest.getDiaryDayContentImages()); + makeDiaryImagePermanent(dayRequest.getDiaryDayContentImages()); DiaryDayContent diaryDayContent = DiaryDayContent.builder() .diary(savedDiary) .content(dayRequest.getContent()) @@ -115,6 +116,15 @@ private void saveDiaryDayContent(Diary savedDiary, DiaryCreateRequest request) { } } + private void makeDiaryImagePermanent(String diaryDayContentImages) { + if (!diaryDayContentImages.isEmpty()) { + String[] contentImages = diaryDayContentImages.split(","); + for (String contentImage : contentImages) { + s3Uploader.markImagePermanent(contentImage); + } + } + } + private void updateDiaryDayContent(Diary savedDiary, DiaryUpdateRequest request) { diaryDayContentRepository.deleteById(savedDiary.getId()); for (DiaryUpdateDayRequest dayRequest : request.getDiaryDayRequests()) {