Skip to content

Commit

Permalink
Merge pull request #117 from Na-o-man/feature/#116/sample-photo-delete
Browse files Browse the repository at this point in the history
[FEAT] 회원의 샘플 사진을 모두 삭제하는 함수 구현
  • Loading branch information
bflykky authored Aug 14, 2024
2 parents 78cbf35 + 3c9d0fb commit 403445c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
@Repository
public interface SamplePhotoRepository extends JpaRepository<SamplePhoto, Long> {
boolean existsByMemberId(Long memberId);
void deleteByMemberId(Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public interface PhotoService {
// 특정 공유 그룹의 모든 사진을 삭제하는 함수
void deletePhotoListByShareGroupId(Long shareGroupId);

void deleteSamplePhotoList(Member member);

Photo findPhoto(Long photoId);

boolean hasSamplePhoto(Member member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 403445c

Please sign in to comment.