123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- package com.imed.costaccount.common.util;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.fasterxml.jackson.annotation.JsonInclude;
- import java.io.Serializable;
- import java.math.BigDecimal;
- import java.util.List;
- /**
- * 分页工具类
- *
- * @author Mark sunlightcs@gmail.com
- */
- public class PageUtils implements Serializable {
- private static final long serialVersionUID = 1L;
- /**
- * 总记录数
- */
- private int totalCount;
- /**
- * 每页记录数
- */
- private int pageSize;
- /**
- * 总页数
- */
- private int totalPage;
- /**
- * 当前页数
- */
- private int current;
- /**
- * 列表数据
- */
- private List<?> list;
- /**
- * 归集后的数据总额
- */
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private BigDecimal totalAmount;
-
- /**
- * 分页
- * @param list 列表数据
- * @param totalCount 总记录数
- * @param pageSize 每页记录数
- * @param current 当前页数
- */
- public PageUtils(List<?> list, int totalCount, int pageSize, int current) {
- this.list = list;
- this.totalCount = totalCount;
- this.pageSize = pageSize;
- this.current = current ;
- this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
- }
- /**
- * 分页
- * @param list 列表数据
- * @param totalCount 总记录数
- * @param pageSize 每页记录数
- * @param current 当前页数
- * @param totalAmount 总金额
- */
- public PageUtils(List<?> list, int totalCount, int pageSize, int current,BigDecimal totalAmount) {
- this.list = list;
- this.totalCount = totalCount;
- this.pageSize = pageSize;
- this.current = current ;
- this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
- this.totalAmount = totalAmount;
- }
- /**
- * 分页
- */
- public PageUtils(IPage<?> page) {
- this.list = page.getRecords();
- this.totalCount = (int)page.getTotal();
- this.pageSize = (int)page.getSize();
- this.current = (int)page.getCurrent();
- this.totalPage = (int)page.getPages();
- }
- public int getTotalCount() {
- return totalCount;
- }
- public void setTotalCount(int totalCount) {
- this.totalCount = totalCount;
- }
- public int getPageSize() {
- return pageSize;
- }
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
- public int getTotalPage() {
- return totalPage;
- }
- public void setTotalPage(int totalPage) {
- this.totalPage = totalPage;
- }
- public int getCurrent() {
- return current;
- }
- public void setCurrent(int current) {
- this.current = current;
- }
- public List<?> getList() {
- return list;
- }
- public void setList(List<?> list) {
- this.list = list;
- }
- public static long getSerialVersionUID() {
- return serialVersionUID;
- }
- public BigDecimal getTotalAmount() {
- return totalAmount;
- }
- public void setTotalAmount(BigDecimal totalAmount) {
- this.totalAmount = totalAmount;
- }
- }
|