schoollist.js 881 Bytes
import { getUrlParams } from './utils';

export function schoolList(count) {
  const list = [];
  for (let i = 0; i < count; i += 1) {
    list.push({
      key: i,
      id: `fake-list-${i}`,
      name:`学校名字-${i}`,
      corp:`企业号代码${i}`,
      avatar:'XXX',
      updatedAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)),
      createdAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)),
    });
  }
  return list;
}


export function getSchoolLists(req, res, u) {
    let url = u;
    if (!url || Object.prototype.toString.call(url) !== '[object String]') {
      url = req.url; // eslint-disable-line
    }
  
    const params = getUrlParams(url);
  
    const count = (params.pageSize * 1) || 20;
  
    const result = schoolList(count);
  
    if (res && res.json) {
      res.json(result);
    } else {
      return result;
    }
  }