From 3c9d0fb8003d51e22888df3518c3e70e596dc71a Mon Sep 17 00:00:00 2001 From: bflykky Date: Wed, 14 Aug 2024 17:54:01 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=83=98=ED=94=8C=20=ED=8F=AC=ED=86=A0?= =?UTF-8?q?=20=EB=AA=A8=EB=91=90=20=EC=82=AD=EC=A0=9C=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../photo/repository/SamplePhotoRepository.java | 1 + .../naoman/domain/photo/service/PhotoService.java | 2 ++ .../domain/photo/service/PhotoServiceImpl.java | 12 ++++++++++++ 3 files changed, 15 insertions(+) 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);