Skip to content

Commit

Permalink
feat: 특정 일정의 특정 이미지를 삭제하는 비즈니스 코드 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
yo0oni committed Aug 10, 2024
1 parent 9af73ff commit 51fdb18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.isp.backend.domain.scheduleImage.service;

import org.springframework.http.ResponseEntity;

public interface DeleteScheduleImageService {
ResponseEntity<Void> delete(Long scheduleImageId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -45,4 +47,14 @@ public ReadScheduleImageResponse read(Long scheduleId) {

return new ReadScheduleImageResponse(scheduleId, pathSaveDateMap);
}

@Override
public ResponseEntity<Void> delete(Long scheduleImageId) {
if (!scheduleImageRepository.existsById(scheduleImageId)) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}

scheduleImageRepository.deleteById(scheduleImageId);
return ResponseEntity.noContent().build();
}
}

0 comments on commit 51fdb18

Please sign in to comment.