12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package es.uv.garcosda.models;
- import java.io.Serializable;
- import java.util.List;
- import org.springframework.data.domain.Page;
- import es.uv.garcosda.domain.Post;
- public class PostsResponseDTO implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private List<Post> posts;
- private long totalRecords;
- private int currentPage;
- private int pageSize;
- private boolean hasNextPage;
- private boolean hasPrevPage;
-
- public PostsResponseDTO() { }
-
- public PostsResponseDTO(List<Post> posts, long totalRecords, int currentPage, int pageSize, boolean hasNextPage, boolean hasPrevPage) {
- this.posts = posts;
- this.totalRecords = totalRecords;
- this.currentPage = currentPage;
- this.pageSize = pageSize;
- this.hasNextPage = hasNextPage;
- this.hasPrevPage = hasPrevPage;
- }
- public PostsResponseDTO(Page<Post> pageData) {
- this.posts = pageData.getContent();
- this.totalRecords = pageData.getTotalElements();
- this.currentPage = pageData.getNumber();
- this.pageSize = pageData.getSize();
- this.hasNextPage = pageData.hasNext();
- this.hasPrevPage = pageData.hasPrevious();
- }
- public List<Post> getPosts() {
- return posts;
- }
- public long getTotalRecords() {
- return totalRecords;
- }
- public int getCurrentPage() {
- return currentPage;
- }
- public int getPageSize() {
- return pageSize;
- }
- public boolean isHasNextPage() {
- return hasNextPage;
- }
- public boolean isHasPrevPage() {
- return hasPrevPage;
- }
-
- }
|