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 d3a2cc5 commit 28b309a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ public ResultResponse<PhotoDownloadUrlListInfo> getPhotoDownloadUrlList(@Request
}

@GetMapping("/download/all")
@Operation(summary = "특정 공유그룹의 사진 전체 다운로드 API", description = "사용자가 속한 공유그룹의 전체 사진을 다운로드할 주소를 받는 API입니다. 해당 공유그룹에 속해있는 회원만 다운로드 요청할 수 있습니다.")
@Parameters(value = {
@Parameter(name = "shareGroupId", description = "다운로드할 사진이 있는 공유그룹의 아이디를 입력해주세요."),
})
public ResultResponse<PhotoDownloadUrlListInfo> 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 = "다운로드할 사진이 있는 공유그룹의 아이디를 입력해주세요."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

@Repository
public interface PhotoRepository extends JpaRepository<Photo, Long> {
List<Photo> findByIdInAndShareGroupId(List<Long> photoIdList, Long shareGroupId);

List<Photo> findByIdIn(List<Long> photoIdList);

List<Photo> findByShareGroupId(Long ShareGroupId);

List<Photo> findByIdInAndShareGroupId(List<Long> photoIdList, Long shareGroupId);

@Modifying
@Query("DELETE FROM Photo p WHERE p.id IN :photoIdList")
void deleteAllByPhotoIdList(@Param("photoIdList") List<Long> photoIdList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public interface PhotoService {

PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List<Long> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ public PhotoDownloadUrlListInfo getPhotoDownloadUrlList(List<Long> photoIdList,
return photoConverter.toPhotoDownloadUrlListInfo(photoUrlList);
}

@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)
.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);
Expand Down

0 comments on commit 28b309a

Please sign in to comment.