Skip to content

Commit

Permalink
feat : 특정 공유그룹의 사진 전체 다운로드 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jjeongdong committed Aug 23, 2024
1 parent 076ddce commit 938b042
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,25 @@ public PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List<Long> photoIdList,
@Override
public PhotoDownloadUrlListInfo getPhotoDownloadUrlListByShareGroup(Long shareGroupId, Member member) {
validateShareGroupAndProfile(shareGroupId, member);
List<Photo> photoList = photoRepository.findByShareGroupId(shareGroupId);

List<String> photoUrlList = photoList.stream()
.map(Photo::getUrl)
List<PhotoEs> photoEsList = new ArrayList<>();
Pageable pageable = Pageable.ofSize(5000);
boolean isLastPage = false;

while (!isLastPage) {
Page<PhotoEs> photoEsPage = photoEsClientRepository.findPhotoEsByShareGroupId(shareGroupId, pageable);
photoEsList.addAll(photoEsPage.getContent());
isLastPage = photoEsPage.isLast();

// 다음 페이지로 이동
pageable = pageable.next();
}

List<String> photoUrlList = photoEsList.stream()
.map(PhotoEs::getUrl)
.collect(Collectors.toList());

// 사진 다운로드 이력 추가
photoEsClientRepository.addDownloadTag(photoUrlList, member.getId());

return photoConverter.toPhotoDownloadUrlListInfo(photoUrlList);
Expand Down

0 comments on commit 938b042

Please sign in to comment.