user.js 3.2 KB

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