整理代码。

This commit is contained in:
2023-04-15 20:16:21 +08:00
parent f1300e9a5c
commit 1959d1b2cb
9 changed files with 113 additions and 139 deletions

View File

@@ -18,6 +18,8 @@ package xyz.zhouxy.plusone.commons.util;
import java.util.List;
import javax.annotation.Nonnull;
/**
* 返回分页查询的结果
*
@@ -28,38 +30,31 @@ import java.util.List;
*/
public class PageDTO<T> {
private Long total;
private List<T> content;
@Nonnull
private final Long total;
@Nonnull
private final List<T> content;
private PageDTO(List<T> content, Long total) {
private PageDTO(@Nonnull List<T> content, @Nonnull Long total) {
this.content = content;
this.total = total;
}
public static <T> PageDTO<T> of(List<T> content, Long total) {
@Nonnull
public static <T> PageDTO<T> of(@Nonnull List<T> content, @Nonnull Long total) {
return new PageDTO<>(content, total);
}
@Nonnull
public Long getTotal() {
return total;
}
@Nonnull
public List<T> getContent() {
return content;
}
// Setters
public void setTotal(Long total) {
this.total = total;
}
public void setContent(List<T> content) {
this.content = content;
}
// Setters end
@Override
public String toString() {
return "PageDTO [total=" + total + ", content=" + content + "]";