Skip to content

Commit

Permalink
나의 콜렉션 조회 응답에 폴더 이름도 응답하도록 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
pparkjs committed Oct 27, 2024
1 parent 3f53702 commit 3de5741
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
public record CollectionResponse(
Long cursorId,
Boolean hasNext,
List<CollectionListsResponse> collectionLists
List<CollectionListsResponse> collectionLists,
String folderName
) {

public static CollectionResponse of(Long cursorId, Boolean hasNext, List<Collect> collects) {
return new CollectionResponse(cursorId, hasNext, toList(collects));
public static CollectionResponse of(
Long cursorId,
Boolean hasNext,
List<Collect> collects,
String folderName
) {
return new CollectionResponse(cursorId, hasNext, toList(collects), folderName);
}

public static List<CollectionListsResponse> toList(List<Collect> collects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ private void addCollect(ListEntity list, User user, Folder folder) {

public CollectionResponse getCollection(Long loginUserId, Long cursorId, Pageable pageable, Long folderId) {
User user = userRepository.getById(loginUserId);
folderRepository.getById(folderId);
Folder folder = folderRepository.getById(folderId);
Slice<Collect> result = collectionRepository.getAllCollectionList(cursorId, pageable, user.getId(), folderId);
List<Collect> collectionList = result.getContent();

cursorId = null;
if (!collectionList.isEmpty()) {
cursorId = collectionList.get(collectionList.size() - 1).getId();
}
return CollectionResponse.of(cursorId, result.hasNext(), collectionList);
return CollectionResponse.of(cursorId, result.hasNext(), collectionList, folder.getFolderName());
}

public List<CategoryTypeResponse> getCategoriesOfCollection(Long loginUserId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.listywave.collection.application.domain.QCollect.collect;
import static com.listywave.common.util.PaginationUtils.checkEndPage;
import static com.listywave.list.application.domain.category.CategoryType.ENTIRE;
import static com.listywave.list.application.domain.item.QItem.item;
import static com.listywave.list.application.domain.list.QListEntity.listEntity;
import static com.listywave.user.application.domain.QUser.user;
Expand Down

0 comments on commit 3de5741

Please sign in to comment.