PageUtils.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package com.kmall.common.utils;
  2. import java.io.Serializable;
  3. import java.util.List;
  4. /**
  5. * 分页工具类
  6. *
  7. * @author Scott
  8. * @email
  9. * @date 2016年11月4日 下午12:59:00
  10. */
  11. public class PageUtils implements Serializable {
  12. private static final long serialVersionUID = 1L;
  13. //总记录数
  14. private int totalCount;
  15. //每页记录数
  16. private int pageSize;
  17. //总页数
  18. private int totalPage;
  19. //当前页数
  20. private int currPage;
  21. //列表数据
  22. private List<?> list;
  23. /**
  24. * 分页
  25. *
  26. * @param list 列表数据
  27. * @param totalCount 总记录数
  28. * @param pageSize 每页记录数
  29. * @param currPage 当前页数
  30. */
  31. public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
  32. this.list = list;
  33. this.totalCount = totalCount;
  34. this.pageSize = pageSize;
  35. this.currPage = currPage;
  36. this.totalPage = (int) Math.ceil((double) totalCount / pageSize);
  37. }
  38. public int getTotalCount() {
  39. return totalCount;
  40. }
  41. public void setTotalCount(int totalCount) {
  42. this.totalCount = totalCount;
  43. }
  44. public int getPageSize() {
  45. return pageSize;
  46. }
  47. public void setPageSize(int pageSize) {
  48. this.pageSize = pageSize;
  49. }
  50. public int getTotalPage() {
  51. return totalPage;
  52. }
  53. public void setTotalPage(int totalPage) {
  54. this.totalPage = totalPage;
  55. }
  56. public int getCurrPage() {
  57. return currPage;
  58. }
  59. public void setCurrPage(int currPage) {
  60. this.currPage = currPage;
  61. }
  62. public List<?> getList() {
  63. return list;
  64. }
  65. public void setList(List<?> list) {
  66. this.list = list;
  67. }
  68. }