|
- package com.ningdatech.kqapi.common.model;
-
- import lombok.Data;
- import lombok.NoArgsConstructor;
-
- import java.util.Collection;
- import java.util.Collections;
-
- /**
- * <p>
- * PageVo - 分页返回的包装对象
- * </p>
- *
- * @author WendyYang
- * @since 14:43 2022/9/29
- */
- @Data
- @NoArgsConstructor
- public class PageVo<T> {
-
- private Collection<T> records;
- private Long total;
-
- private Boolean hasNextPage;
-
- public PageVo(Collection<T> records, Boolean hasNextPage) {
- this.records = records;
- this.hasNextPage = hasNextPage;
- }
-
- public PageVo(Collection<T> records, Long total) {
- this.records = records;
- this.total = total;
- }
-
- public void setTotal(Long total) {
- this.total = total;
- }
-
- public static <T> PageVo<T> of(Collection<T> data, Long total) {
- return new PageVo<>(data, total);
- }
-
- public static <T> PageVo<T> of(Collection<T> data, Integer total) {
- return new PageVo<>(data, (long) total);
- }
-
- /**
- * 移动端无需展示总页码使用
- *
- * @param data 分页数据
- * @param hasNextPage 是否有下一页
- * @author WendyYang
- **/
- public static <T> PageVo<T> of(Collection<T> data, Boolean hasNextPage) {
- return new PageVo<>(data, hasNextPage);
- }
-
- public static <T> PageVo<T> empty() {
- return new PageVo<>(Collections.emptyList(), 0L);
- }
-
- }
|