PageDTO.java
1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.wondertek.util;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.ToString;
import java.util.ArrayList;
import java.util.List;
/**
* 分页对象
*
* @param <T>
*/
@Data
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PageDTO<T> {
/**
* 总的页数
*/
private Integer totalPage;
/**
* 总记录数
*/
private Long totalCount;
/**
* 分页数据
*/
private List<T> list;
public PageDTO() {}
/**
*
* @param totalPage 总页数
* @param totalCount 总数
* @param list
*/
public <K> PageDTO(Integer totalPage, Long totalCount, List<T> list) {
this.totalPage = totalPage;
this.totalCount = totalCount;
this.list = list;
}
public static <T> PageDTO<T> ok(Integer totalPage, Long totalCount, List<T> list){
return new PageDTO<>(totalPage, totalCount, list);
}
public static <T> PageDTO<T> empty() {
return new PageDTO<>(0, 0L, new ArrayList<>());
}
}