Skip to content

Commit

Permalink
fix: 다이어리 삭제 시 이미지 null 체크
Browse files Browse the repository at this point in the history
  • Loading branch information
DrumRobot committed Apr 2, 2024
1 parent a385ecb commit 6304d11
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/picdiary/diary/controller/DiaryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public ApplicationResponse<Long> updateDiary(@Parameter(hidden = true) UserEntit
@DeleteMapping("/{diaryId}")
public ApplicationResponse<Long> deleteDiary(@Parameter(hidden = true) UserEntity user, @PathVariable("diaryId") Long diaryId) {
DiaryEntity diary = diaryService.findDiaryById(diaryId);
s3Service.deleteImage(diary.getImageFileName());
diaryService.deleteDiary(user.getId(), diaryId);
if (diary.getImageFileName() != null) {
s3Service.deleteImage(diary.getImageFileName());
}
diaryService.deleteDiary(user.getId(), diary);
return ApplicationResponse.success(diaryId, "다이어리가 삭제되었습니다.");
}
}

0 comments on commit 6304d11

Please sign in to comment.