export class Pagination<T> {
  sortBy: string;
  descending: boolean;
  page: number; // 页码
  rowsPerPage: number; // 每页条数
  rowsNumber: number; // 总数量
  data: T;

  constructor(t: T) {
    this.sortBy = 'desc';
    this.descending = false;
    this.page = 1;
    this.rowsPerPage = 20;
    this.rowsNumber = 10;
    this.data = t;
  }
}

export function convert<T, R>(
  val1: Pagination<T>,
  val2: Common.pageResult<R>
): Pagination<T> {
  val1.sortBy = val2.sortBy;
  val1.descending = val2.descending;
  val1.page = val2.page;
  val1.rowsPerPage = val2.rowsPerPage;
  val1.rowsNumber = val2.rowsNumber;
  return val1;
}

export function cconvert<T, R>(
  val1: Pagination<T>,
  val2: Common.cpageResult<R>
): Pagination<T> {
  val1.page = val2.currentPage;
  val1.rowsPerPage = val2.pageSize;
  val1.rowsNumber = val2.totalCount;
  return val1;
}

/** *****************  Permission  *****************************************************/
export class MenuSearchEntity {
  dictType: string;

  constructor(dictType = '') {
    this.dictType = dictType;
  }
}
