首页>代码>eclipse+spring+mybatis+Atomikos+maven实现简易分布式数据库读写分离>/jta-db-1.0.0/src/main/java/com/dcliu/db/Page.java
package com.dcliu.db;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Page<T extends Object> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 当前页
*/
private int page = 1;
/**
* 每页记录数
*/
private int size = 15;
/**
* 总记录数
*/
private int count;
/**
* 结果集
*/
@SuppressWarnings("unchecked")
private List<T> result = Collections.EMPTY_LIST;
/**
* 参数
*/
private Map<String, Object> params = new HashMap<String, Object>();
/**
* 分页的开始
*/
public int getStartNum() {
if (page > 1)
return (page - 1) * size;
return 0;
}
/**
* 分页的结束
*/
public int getEndNum() {
if (page < this.getPageCount())
return (page + 1) * size - 1;
return count - 1;
}
/**
* 总页数
*/
public int getPageCount() {
if (count > 0) {
int pageCount = count / size;
if(count % size == 0) {
return pageCount;
} else {
return pageCount + 1;
}
}
return 0;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page <= 0 ? 1 : page;
}
public void setPage(Object page) {
try {
if (page == null)
this.page = 1;
else {
int _page = Integer.parseInt(page.toString());
this.page = _page <= 0 ? 1 : _page;
}
} catch (Exception e) {
this.page = 1;
}
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size <= 0 ? 1 : size;
}
public void setSize(Object size) {
try {
if (size == null)
this.size = 20;
else {
int _size = Integer.parseInt(size.toString());
this.size = _size <= 0 ? 1 : _size;
}
} catch (Exception e) {
this.size = 20;
}
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public List<T> getResult() {
return result;
}
public void setResult(List<T> result) {
this.result = result;
}
public Map<String, Object> getParams() {
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
}
最近下载更多
最近浏览更多
llllllK LV5
2024年5月13日
微信网友_6813145916592128
2024年1月8日
暂无贡献等级
lujinchao1111 LV4
2023年6月25日
admin1234545545 LV3
2022年11月10日
lcbaaa LV6
2022年8月13日
是你爸爸啊100 LV5
2022年8月5日
小星超级爱编程 LV17
2022年1月21日
szf123 LV12
2021年11月13日
wwww1984 LV14
2021年10月31日
赵小胖
2021年6月17日
暂无贡献等级

