schoollist.js 1.09 KB
import { getUrlParams } from './utils';

export function schoolList(count,filter) {
  const list = [];
  for (let i = 0; i < count; i += 1) {
    var temp = new String(i);
    if((!filter)|| temp.indexOf(filter)>=0){
      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);
  
    console.log('server side recevice params:')
    console.log(url);
    console.log(params);

    const count = (params.pageSize * 1) || 40;
  
    const result = schoolList(count,params.name);
  
    if (res && res.json) {
      res.json({'list':result,'pagination':1});
    } else {
      return result;
    }
  }