From 51fdb18e9ebfeef80732dc9314eb42295113b9ca Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:25:00 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8A=B9=EC=A0=95=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=EC=9D=98=20=ED=8A=B9=EC=A0=95=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EB=B9=84?= =?UTF-8?q?=EC=A6=88=EB=8B=88=EC=8A=A4=20=EC=BD=94=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DeleteScheduleImageService.java | 7 +++++++ .../service/ScheduleImageService.java | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java new file mode 100644 index 00000000..d51d5e01 --- /dev/null +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java @@ -0,0 +1,7 @@ +package com.isp.backend.domain.scheduleImage.service; + +import org.springframework.http.ResponseEntity; + +public interface DeleteScheduleImageService { + ResponseEntity delete(Long scheduleImageId); +} \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java index 075e2b8c..ad83f983 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java @@ -9,6 +9,8 @@ import com.isp.backend.domain.scheduleImage.repository.ScheduleImageRepository; import com.isp.backend.domain.scheduleImage.repository.ScheduleImageS3Repository; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -18,7 +20,7 @@ @Service @RequiredArgsConstructor -public class ScheduleImageService implements SaveScheduleImageService, ReadScheduleImageService { +public class ScheduleImageService implements SaveScheduleImageService, ReadScheduleImageService, DeleteScheduleImageService { private final ScheduleImageS3Repository scheduleImageS3Repository; private final ScheduleRepository scheduleRepository; @@ -45,4 +47,14 @@ public ReadScheduleImageResponse read(Long scheduleId) { return new ReadScheduleImageResponse(scheduleId, pathSaveDateMap); } + + @Override + public ResponseEntity delete(Long scheduleImageId) { + if (!scheduleImageRepository.existsById(scheduleImageId)) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); + } + + scheduleImageRepository.deleteById(scheduleImageId); + return ResponseEntity.noContent().build(); + } } \ No newline at end of file