Page.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * Copyright (c) 2011-2014, hubin (jobob@qq.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. * <p>
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.baomidou.mybatisplus.plugins;
  17. import java.util.Collections;
  18. import java.util.List;
  19. import java.util.Map;
  20. import com.baomidou.mybatisplus.plugins.pagination.Pagination;
  21. /**
  22. * <p>
  23. * 实现分页辅助类
  24. * </p>
  25. *
  26. * @author hubin
  27. * @Date 2016-03-01
  28. */
  29. public class Page<T> extends Pagination {
  30. private static final long serialVersionUID = 1L;
  31. /**
  32. * 查询数据列表
  33. */
  34. private List<T> records = Collections.emptyList();
  35. /**
  36. * 查询参数
  37. */
  38. private Map<String, Object> condition;
  39. public Page() {
  40. /* 注意,传入翻页参数 */
  41. }
  42. public Page(int current, int size) {
  43. super(current, size);
  44. }
  45. public Page(int current, int size, String orderByField) {
  46. super(current, size);
  47. this.setOrderByField(orderByField);
  48. }
  49. public List<T> getRecords() {
  50. return records;
  51. }
  52. public Page<T> setRecords(List<T> records) {
  53. this.records = records;
  54. return this;
  55. }
  56. public Map<String, Object> getCondition() {
  57. return condition;
  58. }
  59. public Page<T> setCondition(Map<String, Object> condition) {
  60. this.condition = condition;
  61. return this;
  62. }
  63. @Override
  64. public String toString() {
  65. StringBuilder pg = new StringBuilder();
  66. pg.append(" Page:{ [").append(super.toString()).append("], ");
  67. if (records != null) {
  68. pg.append("records-size:").append(records.size());
  69. } else {
  70. pg.append("records is null");
  71. }
  72. return pg.append(" }").toString();
  73. }
  74. }