VisualPagination.java 944 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package jnpf.visualdata.model;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import io.swagger.v3.oas.annotations.media.Schema;
  4. import lombok.Data;
  5. import java.util.List;
  6. /**
  7. *
  8. *
  9. * @author JNPF开发平台组
  10. * @version V3.1.0
  11. * @copyright 引迈信息技术有限公司
  12. * @date 2021年6月15日
  13. */
  14. @Data
  15. public class VisualPagination {
  16. @Schema(description ="每页条数",example = "10")
  17. private long size=10;
  18. @Schema(description ="当前页数",example = "1")
  19. private long current=1;
  20. @Schema(hidden = true)
  21. private long total;
  22. @Schema(hidden = true)
  23. private long pages;
  24. public <T> List<T> setData(IPage<T> page) {
  25. this.total = page.getTotal();
  26. if (this.total > 0) {
  27. this.pages = this.total % this.size == 0 ? this.total / this.size : this.total / this.size + 1;
  28. } else {
  29. this.pages = 0L;
  30. }
  31. return page.getRecords();
  32. }
  33. }