diff --git a/src/main/java/com/umc/naoman/domain/photo/controller/PhotoController.java b/src/main/java/com/umc/naoman/domain/photo/controller/PhotoController.java index 35caee3..bb7e941 100644 --- a/src/main/java/com/umc/naoman/domain/photo/controller/PhotoController.java +++ b/src/main/java/com/umc/naoman/domain/photo/controller/PhotoController.java @@ -124,6 +124,10 @@ public ResultResponse getEtcPhotoListByShareGroup(@RequestParam @GetMapping("/download") @Operation(summary = "사진 다운로드 API", description = "여러장의 사진을 다운로드할 주소를 받는 API입니다. 해당 공유그룹에 속해있는 회원만 다운로드 요청할 수 있습니다.") + @Parameters(value = { + @Parameter(name = "photoIdList", description = "다운로드할 사진의 아이디를 입력해주세요."), + @Parameter(name = "shareGroupId", description = "다운로드할 사진이 있는 공유그룹의 아이디를 입력해주세요.") + }) public ResultResponse getPhotoDownloadUrlList(@RequestParam List photoIdList, @RequestParam Long shareGroupId, @LoginMember Member member) { @@ -133,11 +137,26 @@ public ResultResponse getPhotoDownloadUrlList(@Request @GetMapping("/download/all") @Operation(summary = "특정 앨범 사진 전체 다운로드 API", description = "선택한 앨범에 속한 사진을 다운로드할 주소를 받는 API입니다. 해당 공유그룹에 속해있는 회원만 다운로드 요청할 수 있습니다.") + @Parameters(value = { + @Parameter(name = "shareGroupId", description = "다운로드할 사진이 있는 공유그룹의 아이디를 입력해주세요."), + @Parameter(name = "profileId", description = "다운로드할 앨범의 아이디를 입력해주세요.") + }) public ResultResponse getPhotoDownloadUrlListByProfile(@RequestParam Long shareGroupId, - @RequestParam Long profileId, - @LoginMember Member member) { - PhotoResponse.PhotoDownloadUrlListInfo photoEsDownloadUrlList = photoService.getPhotoEsDownloadUrlList(shareGroupId, profileId, member); - return ResultResponse.of(DOWNLOAD_PHOTO, photoEsDownloadUrlList); + @RequestParam Long profileId, + @LoginMember Member member) { + PhotoResponse.PhotoDownloadUrlListInfo photoDownloadUrlList = photoService.getPhotoDownloadUrlListByProfile(shareGroupId, profileId, member); + return ResultResponse.of(DOWNLOAD_PHOTO, photoDownloadUrlList); + } + + @GetMapping("/download/etc") + @Operation(summary = "아무도 인식되지 않은 사진 전체 다운로드 API", description = "아무도 인식되지 않은 사진 전체를 다운로드할 주소를 받는 API입니다. 해당 공유그룹에 속해있는 회원만 다운로드 요청할 수 있습니다.") + @Parameters(value = { + @Parameter(name = "shareGroupId", description = "다운로드할 사진이 있는 공유그룹의 아이디를 입력해주세요.") + }) + public ResultResponse getEtcPhotoDownloadUrlList(@RequestParam Long shareGroupId, + @LoginMember Member member) { + PhotoResponse.PhotoDownloadUrlListInfo photoDownloadUrlList = photoService.getEtcPhotoDownloadUrlList(shareGroupId, member); + return ResultResponse.of(DOWNLOAD_PHOTO, photoDownloadUrlList); } @DeleteMapping 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 6c93ecc..dc7d629 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 @@ -20,7 +20,9 @@ public interface PhotoService { PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List photoIdList, Long shareGroupId, Member member); - PhotoDownloadUrlListInfo getPhotoEsDownloadUrlList(Long shareGroupId, Long profileId, Member member); + PhotoDownloadUrlListInfo getPhotoDownloadUrlListByProfile(Long shareGroupId, Long profileId, Member member); + + PhotoDownloadUrlListInfo getEtcPhotoDownloadUrlList(Long shareGroupId, Member member); List deletePhotoList(PhotoRequest.PhotoDeletedRequest request, 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 e605500..0d9c7aa 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 @@ -210,7 +210,7 @@ public PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List photoIdList, } @Override - public PhotoDownloadUrlListInfo getPhotoEsDownloadUrlList(Long shareGroupId, Long profileId, Member member) { + public PhotoDownloadUrlListInfo getPhotoDownloadUrlListByProfile(Long shareGroupId, Long profileId, Member member) { validateShareGroupAndProfile(shareGroupId, member); Long memberId = shareGroupService.findProfile(profileId).getMember().getId(); @@ -234,6 +234,30 @@ public PhotoDownloadUrlListInfo getPhotoEsDownloadUrlList(Long shareGroupId, Lon return photoConverter.toPhotoDownloadUrlListInfo(photUrlList); } + @Override + public PhotoDownloadUrlListInfo getEtcPhotoDownloadUrlList(Long shareGroupId, Member member) { + validateShareGroupAndProfile(shareGroupId, member); + + List photoEsList = new ArrayList<>(); + Pageable pageable = Pageable.ofSize(5000); + boolean isLastPage = false; + + while (!isLastPage) { + Page photoEsPage = photoEsClientRepository.findPhotoEsByShareGroupIdAndNotFaceTag(shareGroupId, pageable); + photoEsList.addAll(photoEsPage.getContent()); + isLastPage = photoEsPage.isLast(); + + // 다음 페이지로 이동 + pageable = pageable.next(); + } + + List photUrlList = photoEsList.stream() + .map(PhotoEs::getUrl) + .collect(Collectors.toList()); + + return photoConverter.toPhotoDownloadUrlListInfo(photUrlList); + } + @Override @Transactional public List deletePhotoList(PhotoRequest.PhotoDeletedRequest request, Member member) {