From 7f2692993ba65cca2fca2a99d13816eb81fd522b Mon Sep 17 00:00:00 2001 From: joonghyun Date: Thu, 6 Jun 2024 11:11:58 +0900 Subject: [PATCH] =?UTF-8?q?#88=20fix:=20=EC=95=A8=EB=B2=94=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=B0=B8=EC=97=AC?= =?UTF-8?q?=20=EB=A9=A4=EB=B2=84=EC=97=90=20=EA=B4=80=EB=A6=AC=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../album/application/AlbumService.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/lesso/neverland/album/application/AlbumService.java b/src/main/java/com/lesso/neverland/album/application/AlbumService.java index dfefe53..54e413b 100644 --- a/src/main/java/com/lesso/neverland/album/application/AlbumService.java +++ b/src/main/java/com/lesso/neverland/album/application/AlbumService.java @@ -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; @@ -47,9 +48,6 @@ public BaseResponse 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 memberList = album.getPuzzle().getPuzzleMembers().stream() - .map(puzzleMember -> puzzleMember.getUser().getProfile().getNickname()).toList(); - List commentList = album.getComments().stream() .filter(comment -> "active".equals(comment.getStatus())) .map(comment -> new CommentDto( @@ -57,13 +55,25 @@ public BaseResponse getAlbumDetail(Long groupIdx, Long albu 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 getMemberList(Album album) { + List 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));