Skip to content

Commit

Permalink
Merge pull request #110 from Na-o-man/feat/#105/phtoto-delete-api
Browse files Browse the repository at this point in the history
[FEAT] 회원 탈퇴시 필요한 사진 삭제 함수 구현
  • Loading branch information
bflykky authored Aug 13, 2024
2 parents 9585288 + 5d2c924 commit 787bca3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public interface PhotoService {

List<Photo> deletePhotoList(PhotoRequest.PhotoDeletedRequest request, Member member);

// 사진 목록에서 특정 회원의 사진을 삭제하는 함수
void deletePhotoListByFaceTag(Long memberId);

// 특정 공유 그룹의 모든 사진을 삭제하는 함수
void deletePhotoListByShareGroupId(Long shareGroupId);

Photo findPhoto(Long photoId);

boolean hasSamplePhoto(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public List<Photo> deletePhotoList(PhotoDeletedRequest request, Member member) {
throw new BusinessException(PHOTO_NOT_FOUND);
}

// 각 사진에 대해 S3에서 객체 삭제 및 데이터베이스에서 삭제
// 각 사진에 대해 S3에서 객체 삭제
for (Photo photo : photoList) {
deletePhoto(photo.getName());
}
Expand All @@ -283,7 +283,42 @@ public List<Photo> deletePhotoList(PhotoDeletedRequest request, Member member) {
photoRepository.deleteAllByPhotoIdList(photoIdList);
photoEsClientRepository.deletePhotoEsByRdsId(photoIdList, request.getShareGroupId());

return photoList; // 삭제된 사진 목록 반환
// 삭제된 사진 목록 반환
return photoList;
}

@Override
@Transactional
public void deletePhotoListByFaceTag(Long memberId) {
// Elasticsearch 사진 데이터 삭제
List<Long> photoIdList = photoEsClientRepository.deletePhotoEsByFaceTag(memberId);

List<Photo> photoList = photoRepository.findByIdIn(photoIdList);

// S3 버킷 사진 데이터 삭제
for (Photo photo : photoList) {
deletePhoto(photo.getName());
}

// RDBMS 사진 데이터 삭제
photoRepository.deleteAllByPhotoIdList(photoIdList);
}

@Override
@Transactional
public void deletePhotoListByShareGroupId(Long shareGroupId) {
// Elasticsearch 사진 데이터 삭제
List<Long> photoIdList = photoEsClientRepository.deletePhotoEsByShareGroupId(shareGroupId);

List<Photo> photoList = photoRepository.findByIdIn(photoIdList);

// S3 버킷 사진 데이터 삭제
for (Photo photo : photoList) {
deletePhoto(photo.getName());
}

// RDBMS 사진 데이터 삭제
photoRepository.deleteAllByPhotoIdList(photoIdList);
}

private void deletePhoto(String photoName) {
Expand Down

0 comments on commit 787bca3

Please sign in to comment.