|
@@ -37,26 +37,18 @@ public class Pagination<T> implements IPage<T>, Serializable {
|
|
* 查询数据列表
|
|
* 查询数据列表
|
|
*/
|
|
*/
|
|
private List<T> records = Collections.emptyList();
|
|
private List<T> records = Collections.emptyList();
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 总数
|
|
|
|
|
|
+ * 总数,当 total 为 null 或者大于 0 分页插件不在查询总数
|
|
*/
|
|
*/
|
|
- private long total;
|
|
|
|
-
|
|
|
|
|
|
+ private Long total = 0L;
|
|
/**
|
|
/**
|
|
* 每页显示条数,默认 10
|
|
* 每页显示条数,默认 10
|
|
*/
|
|
*/
|
|
private long size = 10;
|
|
private long size = 10;
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 当前页
|
|
* 当前页
|
|
*/
|
|
*/
|
|
private long current = 1;
|
|
private long current = 1;
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询总记录数(默认 true)
|
|
|
|
- */
|
|
|
|
- private boolean searchCount = true;
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* SQL 排序 ASC 集合
|
|
* SQL 排序 ASC 集合
|
|
@@ -84,15 +76,15 @@ public class Pagination<T> implements IPage<T>, Serializable {
|
|
* @param size 每页显示条数
|
|
* @param size 每页显示条数
|
|
*/
|
|
*/
|
|
public Pagination(long current, long size) {
|
|
public Pagination(long current, long size) {
|
|
- this(current, size, true);
|
|
|
|
|
|
+ this(current, size, 0L);
|
|
}
|
|
}
|
|
|
|
|
|
- public Pagination(long current, long size, boolean searchCount) {
|
|
|
|
|
|
+ public Pagination(long current, long size, Long total) {
|
|
if (current > 1) {
|
|
if (current > 1) {
|
|
this.current = current;
|
|
this.current = current;
|
|
}
|
|
}
|
|
this.size = size;
|
|
this.size = size;
|
|
- this.searchCount = searchCount;
|
|
|
|
|
|
+ this.total = total;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -123,24 +115,24 @@ public class Pagination<T> implements IPage<T>, Serializable {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public IPage setRecords(List records) {
|
|
|
|
|
|
+ public IPage<T> setRecords(List records) {
|
|
this.records = records;
|
|
this.records = records;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Pagination setTotal(long total) {
|
|
|
|
|
|
+ public Pagination<T> setTotal(Long total) {
|
|
this.total = total;
|
|
this.total = total;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public long getTotal() {
|
|
|
|
|
|
+ public Long getTotal() {
|
|
return this.total;
|
|
return this.total;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Pagination setSize(long size) {
|
|
|
|
|
|
+ public Pagination<T> setSize(long size) {
|
|
this.size = size;
|
|
this.size = size;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
@@ -151,7 +143,7 @@ public class Pagination<T> implements IPage<T>, Serializable {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Pagination setCurrent(long current) {
|
|
|
|
|
|
+ public Pagination<T> setCurrent(long current) {
|
|
this.current = current;
|
|
this.current = current;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
@@ -161,26 +153,17 @@ public class Pagination<T> implements IPage<T>, Serializable {
|
|
return this.current;
|
|
return this.current;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public boolean searchCount() {
|
|
|
|
- return searchCount;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void setSearchCount(boolean searchCount) {
|
|
|
|
- this.searchCount = searchCount;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public List<String> ascs() {
|
|
public List<String> ascs() {
|
|
return ascs;
|
|
return ascs;
|
|
}
|
|
}
|
|
|
|
|
|
- public Pagination setAscs(List<String> ascs) {
|
|
|
|
|
|
+ public Pagination<T> setAscs(List<String> ascs) {
|
|
this.ascs = ascs;
|
|
this.ascs = ascs;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- public Pagination setAscs(String... ascs) {
|
|
|
|
|
|
+ public Pagination<T> setAscs(String... ascs) {
|
|
if (ArrayUtils.isNotEmpty(ascs)) {
|
|
if (ArrayUtils.isNotEmpty(ascs)) {
|
|
this.ascs = Arrays.asList(ascs);
|
|
this.ascs = Arrays.asList(ascs);
|
|
}
|
|
}
|
|
@@ -192,12 +175,12 @@ public class Pagination<T> implements IPage<T>, Serializable {
|
|
return descs;
|
|
return descs;
|
|
}
|
|
}
|
|
|
|
|
|
- public Pagination setDescs(List<String> descs) {
|
|
|
|
|
|
+ public Pagination<T> setDescs(List<String> descs) {
|
|
this.descs = descs;
|
|
this.descs = descs;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- public Pagination setDescs(String... descs) {
|
|
|
|
|
|
+ public Pagination<T> setDescs(String... descs) {
|
|
if (ArrayUtils.isNotEmpty(descs)) {
|
|
if (ArrayUtils.isNotEmpty(descs)) {
|
|
this.descs = Arrays.asList(descs);
|
|
this.descs = Arrays.asList(descs);
|
|
}
|
|
}
|