diff --git a/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java b/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java index e5107af..74e7032 100644 --- a/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java +++ b/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java @@ -7,4 +7,5 @@ @Repository public interface SamplePhotoRepository extends JpaRepository { boolean existsByMemberId(Long memberId); + void deleteByMemberId(Long memberId); } diff --git a/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java b/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java index 6a1fcb8..a75c1e6 100644 --- a/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java +++ b/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java @@ -32,6 +32,8 @@ public interface PhotoService { // 특정 공유 그룹의 모든 사진을 삭제하는 함수 void deletePhotoListByShareGroupId(Long shareGroupId); + void deleteSamplePhotoList(Member member); + Photo findPhoto(Long photoId); boolean hasSamplePhoto(Member member); diff --git a/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java b/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java index e5eb3e1..1fa0ebf 100644 --- a/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java @@ -18,6 +18,7 @@ import com.umc.naoman.domain.photo.dto.PhotoResponse.SamplePhotoUploadInfo; import com.umc.naoman.domain.photo.elasticsearch.document.PhotoEs; import com.umc.naoman.domain.photo.elasticsearch.repository.PhotoEsClientRepository; +import com.umc.naoman.domain.photo.elasticsearch.repository.SampleFaceVectorClientRepository; import com.umc.naoman.domain.photo.entity.Photo; import com.umc.naoman.domain.photo.entity.SamplePhoto; import com.umc.naoman.domain.photo.repository.PhotoRepository; @@ -52,6 +53,7 @@ public class PhotoServiceImpl implements PhotoService { private final PhotoRepository photoRepository; private final SamplePhotoRepository samplePhotoRepository; private final PhotoEsClientRepository photoEsClientRepository; + private final SampleFaceVectorClientRepository sampleFaceVectorClientRepository; private final PhotoConverter photoConverter; private final SamplePhotoConverter samplePhotoConverter; private final AmazonS3 amazonS3; @@ -330,6 +332,16 @@ public void deletePhotoListByShareGroupId(Long shareGroupId) { photoRepository.deleteAllByPhotoIdList(photoIdList); } + @Override + @Transactional + public void deleteSamplePhotoList(Member member) { + // 엔티티 삭제 (hard delete) + samplePhotoRepository.deleteByMemberId(member.getId()); + + // ElasticSearch 데이터 삭제 + sampleFaceVectorClientRepository.deleteSampleFaceVectorByMemberId(member.getId()); + } + private void deletePhoto(String photoName) { // S3에서 원본 및 변환된 이미지 삭제 s3Template.deleteObject(BUCKET_NAME, RAW_PATH_PREFIX + "/" + photoName);