From 28b309a9301104f7a3635bfb6fbb17106f482fe1 Mon Sep 17 00:00:00 2001 From: Donghoon Jeong <112836685+jjeongdong@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:27:33 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat=20:=20=ED=8A=B9=EC=A0=95=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=EA=B7=B8=EB=A3=B9=EC=9D=98=20=EC=82=AC=EC=A7=84=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=20API?= =?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 --- .../domain/photo/controller/PhotoController.java | 12 ++++++++++++ .../domain/photo/repository/PhotoRepository.java | 6 ++++-- .../naoman/domain/photo/service/PhotoService.java | 2 ++ .../domain/photo/service/PhotoServiceImpl.java | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) 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 06aebf4..5d4ea99 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 @@ -147,6 +147,18 @@ public ResultResponse getPhotoDownloadUrlList(@Request } @GetMapping("/download/all") + @Operation(summary = "특정 공유그룹의 사진 전체 다운로드 API", description = "사용자가 속한 공유그룹의 전체 사진을 다운로드할 주소를 받는 API입니다. 해당 공유그룹에 속해있는 회원만 다운로드 요청할 수 있습니다.") + @Parameters(value = { + @Parameter(name = "shareGroupId", description = "다운로드할 사진이 있는 공유그룹의 아이디를 입력해주세요."), + }) + public ResultResponse getPhotoDownloadUrlListByShareGroup(@RequestParam Long shareGroupId, + @LoginMember Member member) { + PhotoResponse.PhotoDownloadUrlListInfo photoDownloadUrlList = photoService.getPhotoDownloadUrlListByShareGroup(shareGroupId, member); + return ResultResponse.of(DOWNLOAD_PHOTO, photoDownloadUrlList); + } + + + @GetMapping("/download/album") @Operation(summary = "특정 앨범 사진 전체 다운로드 API", description = "선택한 앨범에 속한 사진을 다운로드할 주소를 받는 API입니다. 해당 공유그룹에 속해있는 회원만 다운로드 요청할 수 있습니다.") @Parameters(value = { @Parameter(name = "shareGroupId", description = "다운로드할 사진이 있는 공유그룹의 아이디를 입력해주세요."), diff --git a/src/main/java/com/umc/naoman/domain/photo/repository/PhotoRepository.java b/src/main/java/com/umc/naoman/domain/photo/repository/PhotoRepository.java index 2844e37..497c8ee 100644 --- a/src/main/java/com/umc/naoman/domain/photo/repository/PhotoRepository.java +++ b/src/main/java/com/umc/naoman/domain/photo/repository/PhotoRepository.java @@ -11,10 +11,12 @@ @Repository public interface PhotoRepository extends JpaRepository { - List findByIdInAndShareGroupId(List photoIdList, Long shareGroupId); - List findByIdIn(List photoIdList); + List findByShareGroupId(Long ShareGroupId); + + List findByIdInAndShareGroupId(List photoIdList, Long shareGroupId); + @Modifying @Query("DELETE FROM Photo p WHERE p.id IN :photoIdList") void deleteAllByPhotoIdList(@Param("photoIdList") List photoIdList); 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 7e714cc..9fc7bea 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,6 +20,8 @@ public interface PhotoService { PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List photoIdList, Long shareGroupId, Member member); + PhotoDownloadUrlListInfo getPhotoDownloadUrlListByShareGroup(Long shareGroupId, Member member); + PhotoDownloadUrlListInfo getPhotoDownloadUrlListByProfile(Long shareGroupId, Long profileId, Member member); PhotoDownloadUrlListInfo getEtcPhotoDownloadUrlList(Long shareGroupId, 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 4c0a079..8bf2a2b 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 @@ -240,6 +240,20 @@ public PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List photoIdList, return photoConverter.toPhotoDownloadUrlListInfo(photoUrlList); } + @Override + public PhotoDownloadUrlListInfo getPhotoDownloadUrlListByShareGroup(Long shareGroupId, Member member) { + validateShareGroupAndProfile(shareGroupId, member); + List photoList = photoRepository.findByShareGroupId(shareGroupId); + + List photoUrlList = photoList.stream() + .map(Photo::getUrl) + .collect(Collectors.toList()); + + photoEsClientRepository.addDownloadTag(photoUrlList, member.getId()); + + return photoConverter.toPhotoDownloadUrlListInfo(photoUrlList); + } + @Override public PhotoDownloadUrlListInfo getPhotoDownloadUrlListByProfile(Long shareGroupId, Long profileId, Member member) { validateShareGroupAndProfile(shareGroupId, member); From 076ddce41f887fb30f6d140329518e6bd2a6da81 Mon Sep 17 00:00:00 2001 From: Donghoon Jeong <112836685+jjeongdong@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:30:20 +0900 Subject: [PATCH 2/3] =?UTF-8?q?docs=20:=20=EC=BD=94=EB=93=9C=20=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/umc/naoman/domain/photo/controller/PhotoController.java | 1 - 1 file changed, 1 deletion(-) 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 5d4ea99..41deecf 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 @@ -157,7 +157,6 @@ public ResultResponse getPhotoDownloadUrlListByShareGr return ResultResponse.of(DOWNLOAD_PHOTO, photoDownloadUrlList); } - @GetMapping("/download/album") @Operation(summary = "특정 앨범 사진 전체 다운로드 API", description = "선택한 앨범에 속한 사진을 다운로드할 주소를 받는 API입니다. 해당 공유그룹에 속해있는 회원만 다운로드 요청할 수 있습니다.") @Parameters(value = { From 938b04213b929886920ff1029a40f99e5103d91a Mon Sep 17 00:00:00 2001 From: Donghoon Jeong <112836685+jjeongdong@users.noreply.github.com> Date: Fri, 23 Aug 2024 12:05:37 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat=20:=20=ED=8A=B9=EC=A0=95=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=EA=B7=B8=EB=A3=B9=EC=9D=98=20=EC=82=AC=EC=A7=84=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=20API?= =?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/service/PhotoServiceImpl.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 8bf2a2b..8ce9b33 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 @@ -243,12 +243,25 @@ public PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List photoIdList, @Override public PhotoDownloadUrlListInfo getPhotoDownloadUrlListByShareGroup(Long shareGroupId, Member member) { validateShareGroupAndProfile(shareGroupId, member); - List photoList = photoRepository.findByShareGroupId(shareGroupId); - List photoUrlList = photoList.stream() - .map(Photo::getUrl) + List photoEsList = new ArrayList<>(); + Pageable pageable = Pageable.ofSize(5000); + boolean isLastPage = false; + + while (!isLastPage) { + Page photoEsPage = photoEsClientRepository.findPhotoEsByShareGroupId(shareGroupId, pageable); + photoEsList.addAll(photoEsPage.getContent()); + isLastPage = photoEsPage.isLast(); + + // 다음 페이지로 이동 + pageable = pageable.next(); + } + + List photoUrlList = photoEsList.stream() + .map(PhotoEs::getUrl) .collect(Collectors.toList()); + // 사진 다운로드 이력 추가 photoEsClientRepository.addDownloadTag(photoUrlList, member.getId()); return photoConverter.toPhotoDownloadUrlListInfo(photoUrlList);