Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.backend.photoAlbum.controller;

import cc.backend.apiPayLoad.ApiResponse;
import cc.backend.apiPayLoad.PageResponse;
import cc.backend.apiPayLoad.SliceResponse;
import cc.backend.member.entity.Member;
import cc.backend.photoAlbum.dto.PerformerShowListResponseDTO;
Expand Down Expand Up @@ -60,11 +61,11 @@ public ApiResponse<PhotoAlbumResponseDTO.PhotoAlbumResultWithPresignedUrlDTO> up

@GetMapping("/member/{memberId}")
@Operation(summary = "등록자 계정의 전체 사진첩 피드 조회 API", description = "등록자의 사진첩 피드를 전체 조회하는 API 입니다.")
public ApiResponse<SliceResponse<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO>> getPhotoAlbumList(
public ApiResponse<PageResponse<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO>> getPhotoAlbumList(
@AuthenticationPrincipal(expression = "member") Member member,
@PathVariable("memberId") Long performerId,
@ParameterObject Pageable pageable) {
return ApiResponse.onSuccess(SliceResponse.of(photoAlbumService.getPhotoAlbumList(member.getId(), performerId, pageable)));
return ApiResponse.onSuccess((photoAlbumService.getPhotoAlbumList(member.getId(), performerId, pageable)));
}

@PreAuthorize("hasRole('PERFORMER')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ OR CAST(p.amateurShow.id AS string) LIKE %:keyword%
JOIN a.member m
WHERE m.id = :performerId
""")
Slice<PhotoAlbum> findByPerformerId(
Page<PhotoAlbum> findByPerformerId(
@Param("performerId") Long performerId,
Pageable pageable
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.backend.photoAlbum.service;

import cc.backend.apiPayLoad.PageResponse;
import cc.backend.photoAlbum.dto.PerformerShowListResponseDTO;
import cc.backend.photoAlbum.dto.PhotoAlbumRequestDTO;
import cc.backend.photoAlbum.dto.PhotoAlbumResponseDTO;
Expand All @@ -15,7 +16,7 @@ public interface PhotoAlbumService {

public PhotoAlbumResponseDTO.PhotoAlbumResultWithPresignedUrlDTO createPhotoAlbum(PhotoAlbumRequestDTO.CreatePhotoAlbumDTO requestDTO, Long memberId);
public PhotoAlbumResponseDTO.PhotoAlbumResultWithPresignedUrlDTO getPhotoAlbum(Long photoAlbumId, Long memberId);
public Slice<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> getPhotoAlbumList(Long memberId, Long performerId, Pageable pageable);
public PageResponse<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> getPhotoAlbumList(Long memberId, Long performerId, Pageable pageable);
public PhotoAlbumResponseDTO.PhotoAlbumResultDTO updatePhotoAlbum(Long photoAlbumId, PhotoAlbumRequestDTO.CreatePhotoAlbumDTO requestDTO, Long memberId);
public String deletePhotoAlbum(Long photoAlbumId, Long memberId);
public PhotoAlbumResponseDTO.ScrollMemberPhotoAlbumDTO getAllRecentPhotoAlbumList(Long cursorId, LocalDateTime updatedAt, int size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import cc.backend.amateurShow.entity.AmateurShow;
import cc.backend.amateurShow.repository.AmateurShowRepository;
import cc.backend.apiPayLoad.PageResponse;
import cc.backend.apiPayLoad.code.status.ErrorStatus;
import cc.backend.apiPayLoad.exception.GeneralException;
import cc.backend.config.s3.S3Service;
import cc.backend.image.DTO.ImageRequestDTO;
import cc.backend.image.DTO.ImageResponseDTO;
import cc.backend.image.FilePath;
Expand All @@ -28,7 +28,6 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import static cc.backend.amateurShow.converter.AmateurConverter.mergeSchedule;
Expand Down Expand Up @@ -118,7 +117,7 @@ public PhotoAlbumResponseDTO.PhotoAlbumResultWithPresignedUrlDTO getPhotoAlbum(L
}

@Override
public Slice<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> getPhotoAlbumList(Long memberId, Long performerId, Pageable pageable){
public PageResponse<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> getPhotoAlbumList(Long memberId, Long performerId, Pageable pageable){
//로그인 검사
memberRepository.findById(memberId)
.orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_AUTHORIZED));
Expand All @@ -132,20 +131,19 @@ public Slice<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> getPhotoAlbumList(Long m
);

// 사진첩 단위 조회
Slice<PhotoAlbum> albumSlice = photoAlbumRepository.findByPerformerId(performerId, sortedPageable);
List<PhotoAlbum> albums = albumSlice.getContent();
Page<PhotoAlbum> albumPage = photoAlbumRepository.findByPerformerId(performerId, sortedPageable);

// 사진첩 id 추출
List<Long> albumIds = albums.stream()
List<Long> albumIds = albumPage.stream()
.map(PhotoAlbum::getId)
.toList();

// 대표 이미지 DTO 가져오기 (presigned URL 포함)
Map<Long, ImageResponseDTO.ImageResultWithPresignedUrlDTO> imageDtoMap =
getFirstImageDTOForPhotoAlbums(albumIds);

// DTO 변환
List<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> content = albums.stream()
// DTO 변환 - stream으로 하면 메타데이터 다 날라가서 Page.map()으로 바로 변환
Page<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> content = albumPage
.map(album -> PhotoAlbumResponseDTO.SinglePhotoAlbumDTO.builder()
.amateurShowId(album.getAmateurShow().getId())
.photoAlbumId(album.getId())
Expand All @@ -154,10 +152,9 @@ public Slice<PhotoAlbumResponseDTO.SinglePhotoAlbumDTO> getPhotoAlbumList(Long m
.detailAddress(album.getAmateurShow().getDetailAddress())
.imageResultWithPresignedUrlDTO(imageDtoMap.get(album.getId()))
.build()
)
.toList();
);

return new SliceImpl<>(content, sortedPageable, albumSlice.hasNext());
return PageResponse.of(content);
}

@Override
Expand Down