From 65f25b1e9d35b8ec46b6455db6d437a47970fb67 Mon Sep 17 00:00:00 2001 From: joonghyun Date: Tue, 4 Jun 2024 00:47:37 +0900 Subject: [PATCH] =?UTF-8?q?#111=20fix:=20=EC=8B=9C=EA=B0=84=EC=88=9C=20?= =?UTF-8?q?=EC=95=A8=EB=B2=94=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20=EC=B6=94?= =?UTF-8?q?=EC=96=B5=20=EB=82=A0=EC=A7=9C=EB=A5=BC=20=EA=B8=B0=EC=A4=80?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=A0=95=EB=A0=AC=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../neverland/album/application/AlbumService.java | 10 ++++++++-- .../neverland/album/repository/AlbumRepository.java | 2 +- 2 files changed, 9 insertions(+), 3 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 30c1032..dfefe53 100644 --- a/src/main/java/com/lesso/neverland/album/application/AlbumService.java +++ b/src/main/java/com/lesso/neverland/album/application/AlbumService.java @@ -14,9 +14,11 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.util.Comparator; import java.util.List; import static com.lesso.neverland.common.base.BaseResponseStatus.*; +import static com.lesso.neverland.common.constants.Constants.ACTIVE; @Service @RequiredArgsConstructor @@ -65,10 +67,14 @@ public BaseResponse getAlbumDetail(Long groupIdx, Long albu // 앨범 목록 조회(sortType="time", "location") public BaseResponse getAlbumList(Long groupIdx, String sortType) { Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX)); - List albumList = albumRepository.findByTeamOrderByCreatedDateDesc(group); + + List albumList = albumRepository.findByTeamAndStatusEquals(group, ACTIVE); + List sortedAlbums = albumList.stream() + .sorted(Comparator.comparing(album -> album.getPuzzle().getPuzzleDate(), Comparator.reverseOrder())) + .toList(); if (sortType.equals("time")) { - List albumDtoList = albumList.stream().map(AlbumByTimeDto::from).toList(); + List albumDtoList = sortedAlbums.stream().map(AlbumByTimeDto::from).toList(); return new BaseResponse<>(new AlbumListByTimeResponse(albumDtoList)); } else { List albumDtoList = albumList.stream().map(AlbumByLocationDto::from).toList(); diff --git a/src/main/java/com/lesso/neverland/album/repository/AlbumRepository.java b/src/main/java/com/lesso/neverland/album/repository/AlbumRepository.java index 15d1860..4e7f86e 100644 --- a/src/main/java/com/lesso/neverland/album/repository/AlbumRepository.java +++ b/src/main/java/com/lesso/neverland/album/repository/AlbumRepository.java @@ -8,6 +8,6 @@ import java.util.List; public interface AlbumRepository extends JpaRepository { - List findByTeamOrderByCreatedDateDesc(Team team); + List findByTeamAndStatusEquals(Team team, String status); boolean existsByPuzzle(Puzzle puzzle); }