-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
북마크 폴더에 접근할 시 북마크 리스트를 반환하는 메서드
- Loading branch information
Showing
6 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/mpnp/baechelin/bookmark/dto/BookmarkPagedResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.mpnp.baechelin.bookmark.dto; | ||
|
||
import com.mpnp.baechelin.bookmark.domain.Bookmark; | ||
import com.mpnp.baechelin.store.domain.Store; | ||
import com.mpnp.baechelin.store.dto.StoreCardResponseDto; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class BookmarkPagedResponseDto { | ||
private boolean hasNextPage; | ||
private long totalCount; | ||
private long leftElement; | ||
private int page; | ||
private int totalPage; | ||
private List<BookmarkInfoDto> cards; | ||
|
||
public BookmarkPagedResponseDto(Page<Bookmark> resultStoreList) { | ||
this.hasNextPage = resultStoreList.hasNext(); | ||
this.totalPage = resultStoreList.getTotalPages() - 1; | ||
this.cards = resultStoreList.get().collect(Collectors.toList()).stream().map(BookmarkInfoDto::new).collect(Collectors.toList()); | ||
this.totalCount = resultStoreList.getTotalElements(); | ||
this.page = resultStoreList.getNumber(); | ||
this.leftElement = totalCount - (long) page * resultStoreList.getSize() - resultStoreList.getNumberOfElements(); | ||
this.leftElement = this.leftElement < 0 ? 0 : this.leftElement; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters