package com.shanghaichengdi.ghjgitem.vo.response;

import com.shanghaichengdi.ghjgitem.util.StringUtils;
import java.util.HashMap;

public class ResultRes extends HashMap<String, Object> {

  /**
   * 页码参数
   */
  public static final String PAGE_INDEX = "pageIndex";
  /**
   * 页码参数
   */
  public static final String PAGE_SIZE = "pageSize";
  /**
   * 数据总量
   */
  public static final String TOTAL = "total";

  /**
   * 数据明细
   */
  public static final String ROWS = "rows";

  private static final long serialVersionUID = 1L;

  public ResultRes() {

  }

  public ResultRes(int pageIndex, int pageSize, int total, Object data) {
    super.put(PAGE_INDEX, pageIndex);
    super.put(PAGE_SIZE, pageSize);
    super.put(TOTAL, total);
    if (StringUtils.isNotNull(data)) {
      super.put(ROWS, data);
    }
  }

  public ResultRes(Object data) {
      super.put(ROWS, data);
  }

  public static ResultRes encapsulationResult(int pageIndex, int pageSize, int total, Object data) {
    return new ResultRes(pageIndex, pageSize, total, data);
  }

    public static ResultRes encapsulationResult(Object data) {
    return new ResultRes(data);
  }
}
