Skip to content

Commit 97fcea3

Browse files
Merge pull request #180 from lemonssoju/develop-v2
[develop-v2] main merge
2 parents 6c72b01 + 341cbb3 commit 97fcea3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/com/lesso/neverland/album/application/AlbumService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
import org.springframework.web.multipart.MultipartFile;
1515

1616
import java.io.IOException;
17+
import java.util.Comparator;
1718
import java.util.List;
1819

1920
import static com.lesso.neverland.common.base.BaseResponseStatus.*;
21+
import static com.lesso.neverland.common.constants.Constants.ACTIVE;
2022

2123
@Service
2224
@RequiredArgsConstructor
@@ -65,10 +67,14 @@ public BaseResponse<AlbumDetailResponse> getAlbumDetail(Long groupIdx, Long albu
6567
// 앨범 목록 조회(sortType="time", "location")
6668
public BaseResponse<?> getAlbumList(Long groupIdx, String sortType) {
6769
Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX));
68-
List<Album> albumList = albumRepository.findByTeamOrderByCreatedDateDesc(group);
70+
71+
List<Album> albumList = albumRepository.findByTeamAndStatusEquals(group, ACTIVE);
72+
List<Album> sortedAlbums = albumList.stream()
73+
.sorted(Comparator.comparing(album -> album.getPuzzle().getPuzzleDate(), Comparator.reverseOrder()))
74+
.toList();
6975

7076
if (sortType.equals("time")) {
71-
List<AlbumByTimeDto> albumDtoList = albumList.stream().map(AlbumByTimeDto::from).toList();
77+
List<AlbumByTimeDto> albumDtoList = sortedAlbums.stream().map(AlbumByTimeDto::from).toList();
7278
return new BaseResponse<>(new AlbumListByTimeResponse(albumDtoList));
7379
} else {
7480
List<AlbumByLocationDto> albumDtoList = albumList.stream().map(AlbumByLocationDto::from).toList();

src/main/java/com/lesso/neverland/album/repository/AlbumRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
import java.util.List;
99

1010
public interface AlbumRepository extends JpaRepository<Album, Long> {
11-
List<Album> findByTeamOrderByCreatedDateDesc(Team team);
11+
List<Album> findByTeamAndStatusEquals(Team team, String status);
1212
boolean existsByPuzzle(Puzzle puzzle);
1313
}

0 commit comments

Comments
 (0)