user.js 3.4 KB

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