All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ckjava.http.utils.Page Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package com.ckjava.http.utils;

import java.util.List;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel("分页实体")
public class Page {

	@ApiModelProperty("起始行数")
	private Integer start;
	@ApiModelProperty("每页记录数, 默认30")
	private Integer pageSize = 30;
	@ApiModelProperty("总记录数")
	private Integer totalCount;
	@ApiModelProperty("总页数")
	private Integer pages;
	@ApiModelProperty("当前页记录")
	private List dataList;
	
	public Integer getPages() {
		return pages;
	}
	public void setPages(Integer pages) {
		this.pages = pages;
	}
	public Integer getStart() {
		return start;
	}
	public void setStart(Integer start) {
		this.start = start;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
	}
	public List getDataList() {
		return dataList;
	}
	public void setDataList(List dataList) {
		this.dataList = dataList;
	}
	
	public Page(Integer start, Integer pageSize, Integer totalCount, List dataList) {
		super();
		this.start = start;
		this.pageSize = pageSize;
		this.totalCount = totalCount;
		this.dataList = dataList;
		
		if (totalCount == 0) {
			this.pages = 1;
		} else if (totalCount % pageSize == 0) {
			this.pages = totalCount / pageSize;
		} else {
			this.pages = totalCount / pageSize + 1;
		}
	}

	/**
	 * 获取分页对象
	 * 
	 * @param  任意对象
	 * @param start 起始行数
	 * @param pageSize 每页记录数, 默认30
	 * @param totalCount 总记录数
	 * @param dataList 当前页记录
	 * @return {@code Page } 分页对象 
	 */
	public static  Page getPage(Integer start, Integer pageSize, Integer totalCount, List dataList) {
		return new Page(start, pageSize, totalCount, dataList);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy