user.js 3.02 KB
Newer Older
nikogu's avatar
nikogu committed
1
// 代码中会兼容本地 service mock 以及部署站点的静态数据
愚道's avatar
愚道 committed
2
export default {
3 4
  // 支持值为 Object 和 Array
  'GET /api/currentUser': {
陈帅's avatar
陈帅 committed
5 6 7 8 9 10 11 12 13 14 15
    name: 'Serati Ma',
    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
    userid: '00000001',
    email: 'antdesign@alipay.com',
    signature: '海纳百川,有容乃大',
    title: '交互专家',
    group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
    tags: [
      {
        key: '0',
        label: '很有想法的',
16
      },
陈帅's avatar
陈帅 committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
      {
        key: '1',
        label: '专注设计',
      },
      {
        key: '2',
        label: '辣~',
      },
      {
        key: '3',
        label: '大长腿',
      },
      {
        key: '4',
        label: '川妹子',
      },
      {
        key: '5',
        label: '海纳百川',
      },
    ],
    notifyCount: 12,
    country: 'China',
    geographic: {
      province: {
        label: '浙江省',
        key: '330000',
      },
      city: {
        label: '杭州市',
        key: '330100',
陈帅's avatar
陈帅 committed
48
      },
49
    },
陈帅's avatar
陈帅 committed
50 51
    address: '西湖区工专路 77 号',
    phone: '0752-268888888',
52 53
  },
  // GET POST 可省略
陈帅's avatar
陈帅 committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
  'GET /api/users': [
    {
      key: '1',
      name: 'John Brown',
      age: 32,
      address: 'New York No. 1 Lake Park',
    },
    {
      key: '2',
      name: 'Jim Green',
      age: 42,
      address: 'London No. 1 Lake Park',
    },
    {
      key: '3',
      name: 'Joe Black',
      age: 32,
      address: 'Sidney No. 1 Lake Park',
    },
  ],
74
  'POST /api/login/account': (req, res) => {
afc163's avatar
afc163 committed
75
    const { password, userName, type } = req.body;
陈帅's avatar
陈帅 committed
76
    if (password === '888888' && userName === 'admin') {
ddcat1115's avatar
ddcat1115 committed
77 78 79
      res.send({
        status: 'ok',
        type,
陈帅's avatar
陈帅 committed
80
        currentAuthority: 'admin',
ddcat1115's avatar
ddcat1115 committed
81
      });
陈帅's avatar
陈帅 committed
82
      return;
ddcat1115's avatar
ddcat1115 committed
83
    }
陈帅's avatar
陈帅 committed
84
    if (password === '123456' && userName === 'user') {
ddcat1115's avatar
ddcat1115 committed
85 86 87
      res.send({
        status: 'ok',
        type,
陈帅's avatar
陈帅 committed
88
        currentAuthority: 'user',
ddcat1115's avatar
ddcat1115 committed
89
      });
陈帅's avatar
陈帅 committed
90
      return;
ddcat1115's avatar
ddcat1115 committed
91
    }
afc163's avatar
afc163 committed
92
    res.send({
ddcat1115's avatar
ddcat1115 committed
93
      status: 'error',
afc163's avatar
afc163 committed
94
      type,
陈帅's avatar
陈帅 committed
95
      currentAuthority: 'guest',
afc163's avatar
afc163 committed
96
    });
97 98
  },
  'POST /api/register': (req, res) => {
ddcat1115's avatar
ddcat1115 committed
99
    res.send({ status: 'ok', currentAuthority: 'user' });
100
  },
陈帅's avatar
陈帅 committed
101 102
  'GET /api/500': (req, res) => {
    res.status(500).send({
陈帅's avatar
陈帅 committed
103 104 105 106 107
      timestamp: 1513932555104,
      status: 500,
      error: 'error',
      message: 'error',
      path: '/base/category/list',
陈帅's avatar
陈帅 committed
108 109 110 111
    });
  },
  'GET /api/404': (req, res) => {
    res.status(404).send({
陈帅's avatar
陈帅 committed
112 113 114 115 116
      timestamp: 1513932643431,
      status: 404,
      error: 'Not Found',
      message: 'No message available',
      path: '/base/category/list/2121212',
陈帅's avatar
陈帅 committed
117 118 119 120
    });
  },
  'GET /api/403': (req, res) => {
    res.status(403).send({
陈帅's avatar
陈帅 committed
121 122 123 124 125
      timestamp: 1513932555104,
      status: 403,
      error: 'Unauthorized',
      message: 'Unauthorized',
      path: '/base/category/list',
陈帅's avatar
陈帅 committed
126 127
    });
  },
128 129
  'GET /api/401': (req, res) => {
    res.status(401).send({
陈帅's avatar
陈帅 committed
130 131 132 133 134
      timestamp: 1513932555104,
      status: 401,
      error: 'Unauthorized',
      message: 'Unauthorized',
      path: '/base/category/list',
135 136
    });
  },
137
};