import { resultSuccess, doCustomTimes } from '../_util';

const regionList = (pageSize) => {
  const result: any[] = [];
  doCustomTimes(pageSize, () => {
    result.push({
      id: '@integer(10,999999)',
      name: '@province()',
      'type|1': [1],
      createTime: `@date('yyyy-MM-dd')`,
    });
  });
  return result;
};

export default [
  {
    url: '/api/region/list',
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      const { page = 1, pageSize = 10, name } = query;
      const list = regionList(Number(pageSize));
      //并非真实，只是为了模拟搜索结果
      const count = name ? 30 : 60;
      return resultSuccess({
        page: Number(page),
        pageSize: Number(pageSize),
        totalPage: count,
        totalCount: count * Number(pageSize),
        list,
      });
    },
  },
];
