init
This commit is contained in:
78
src/main/java/com/senmesh/tkmybatis/pojo/Page.java
Normal file
78
src/main/java/com/senmesh/tkmybatis/pojo/Page.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.senmesh.tkmybatis.pojo;
|
||||
|
||||
import com.senmesh.common.dto.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @author guhong
|
||||
* @date 2019/8/19
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class Page<T> implements Serializable, IPage<T> {
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = -729078966440672920L;
|
||||
|
||||
/** 第几页 **/
|
||||
private int pageNo;
|
||||
/** 页宽 **/
|
||||
private int pageSize;
|
||||
/** 一共的页数 **/
|
||||
private int pageCount;
|
||||
/** 记录条数 **/
|
||||
private int totalCount;
|
||||
/** 查询出来的对象实体 **/
|
||||
private List<T> entityList;
|
||||
|
||||
public Page() {
|
||||
pageSize = 20;
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
public Page(int pageNo, int pageSize) {
|
||||
super();
|
||||
this.pageNo = pageNo < 1 ? 1 : pageNo;
|
||||
this.pageSize = pageSize < 1 ? 20 : pageSize;
|
||||
}
|
||||
|
||||
public void setTotalCount(int totalCount) {
|
||||
pageCount = (int) Math.ceil((double) totalCount / pageSize);
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public int getFirstEntityIndex() {
|
||||
return (pageNo - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPageResult(int totalCount, List<T> results) {
|
||||
this.entityList = results;
|
||||
this.setTotalCount(totalCount);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean getNeedPage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user