user.js 3.2KB

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