PageUtils.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package com.imed.costaccount.common.util;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.fasterxml.jackson.annotation.JsonInclude;
  4. import java.io.Serializable;
  5. import java.math.BigDecimal;
  6. import java.util.List;
  7. /**
  8. * 分页工具类
  9. *
  10. * @author Mark sunlightcs@gmail.com
  11. */
  12. public class PageUtils implements Serializable {
  13. private static final long serialVersionUID = 1L;
  14. /**
  15. * 总记录数
  16. */
  17. private int totalCount;
  18. /**
  19. * 每页记录数
  20. */
  21. private int pageSize;
  22. /**
  23. * 总页数
  24. */
  25. private int totalPage;
  26. /**
  27. * 当前页数
  28. */
  29. private int current;
  30. /**
  31. * 列表数据
  32. */
  33. private List<?> list;
  34. /**
  35. * 归集后的数据总额
  36. */
  37. @JsonInclude(JsonInclude.Include.NON_NULL)
  38. private BigDecimal totalAmount;
  39. /**
  40. * 分页
  41. * @param list 列表数据
  42. * @param totalCount 总记录数
  43. * @param pageSize 每页记录数
  44. * @param current 当前页数
  45. */
  46. public PageUtils(List<?> list, int totalCount, int pageSize, int current) {
  47. this.list = list;
  48. this.totalCount = totalCount;
  49. this.pageSize = pageSize;
  50. this.current = current ;
  51. this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
  52. }
  53. /**
  54. * 分页
  55. * @param list 列表数据
  56. * @param totalCount 总记录数
  57. * @param pageSize 每页记录数
  58. * @param current 当前页数
  59. * @param totalAmount 总金额
  60. */
  61. public PageUtils(List<?> list, int totalCount, int pageSize, int current,BigDecimal totalAmount) {
  62. this.list = list;
  63. this.totalCount = totalCount;
  64. this.pageSize = pageSize;
  65. this.current = current ;
  66. this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
  67. this.totalAmount = totalAmount;
  68. }
  69. /**
  70. * 分页
  71. */
  72. public PageUtils(IPage<?> page) {
  73. this.list = page.getRecords();
  74. this.totalCount = (int)page.getTotal();
  75. this.pageSize = (int)page.getSize();
  76. this.current = (int)page.getCurrent();
  77. this.totalPage = (int)page.getPages();
  78. }
  79. public int getTotalCount() {
  80. return totalCount;
  81. }
  82. public void setTotalCount(int totalCount) {
  83. this.totalCount = totalCount;
  84. }
  85. public int getPageSize() {
  86. return pageSize;
  87. }
  88. public void setPageSize(int pageSize) {
  89. this.pageSize = pageSize;
  90. }
  91. public int getTotalPage() {
  92. return totalPage;
  93. }
  94. public void setTotalPage(int totalPage) {
  95. this.totalPage = totalPage;
  96. }
  97. public int getCurrent() {
  98. return current;
  99. }
  100. public void setCurrent(int current) {
  101. this.current = current;
  102. }
  103. public List<?> getList() {
  104. return list;
  105. }
  106. public void setList(List<?> list) {
  107. this.list = list;
  108. }
  109. public static long getSerialVersionUID() {
  110. return serialVersionUID;
  111. }
  112. public BigDecimal getTotalAmount() {
  113. return totalAmount;
  114. }
  115. public void setTotalAmount(BigDecimal totalAmount) {
  116. this.totalAmount = totalAmount;
  117. }
  118. }