Skip to content

Commit

Permalink
Merge pull request #193 from lemonssoju/fix/88-getAlbumDetail
Browse files Browse the repository at this point in the history
[fix/88-getAlbumDetail] 앨범 상세 조회 시 멤버에 관리자도 추가
  • Loading branch information
JoongHyun-Kim authored Jun 6, 2024
2 parents edb4489 + 7f26929 commit a8cd5c2
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

Expand Down Expand Up @@ -47,23 +48,32 @@ public BaseResponse<AlbumDetailResponse> getAlbumDetail(Long groupIdx, Long albu
Album album = albumRepository.findById(albumIdx).orElseThrow(() -> new BaseException(INVALID_ALBUM_IDX));
if (!album.getPuzzle().getTeam().equals(group)) throw new BaseException(NO_GROUP_ALBUM);

List<String> memberList = album.getPuzzle().getPuzzleMembers().stream()
.map(puzzleMember -> puzzleMember.getUser().getProfile().getNickname()).toList();

List<CommentDto> commentList = album.getComments().stream()
.filter(comment -> "active".equals(comment.getStatus()))
.map(comment -> new CommentDto(
comment.getCommentIdx(),
comment.getUser().getProfile().getNickname(),
comment.getUser().getProfile().getProfileImage(),
comment.getCreatedDate().toString(),
comment.getContent())).toList();
comment.getContent()))
.toList();

AlbumDetailResponse albumDetailResponse = new AlbumDetailResponse(album.getPuzzle().getTitle(), album.getPuzzle().getPuzzleDate().toString(),
album.getPuzzle().getLocation().getLocation(), memberList, album.getAlbumImage(), album.getContent(), album.getPuzzle().getPuzzleIdx(), commentList);
album.getPuzzle().getLocation().getLocation(), getMemberList(album), album.getAlbumImage(), album.getContent(), album.getPuzzle().getPuzzleIdx(), commentList);
return new BaseResponse<>(albumDetailResponse);
}

private List<String> getMemberList(Album album) {
List<String> memberList = new ArrayList<>();
memberList.add(album.getPuzzle().getUser().getProfile().getNickname());

memberList.addAll(
album.getPuzzle().getPuzzleMembers().stream()
.map(puzzleMember -> puzzleMember.getUser().getProfile().getNickname())
.toList());
return memberList;
}

// 앨범 목록 조회(sortType="time", "location")
public BaseResponse<?> getAlbumList(Long groupIdx, String sortType) {
Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX));
Expand Down

0 comments on commit a8cd5c2

Please sign in to comment.