tree.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /* eslint-disable import/no-extraneous-dependencies */
  2. /* eslint-disable @typescript-eslint/no-var-requires */
  3. const router = require('express').Router();
  4. const Mock = require('mockjs');
  5. const wrapper = require('../wrapper');
  6. const { Random } = Mock;
  7. router.post('/node', (req, res) => {
  8. res.json(wrapper('success'));
  9. });
  10. router.put('/node', (req, res) => {
  11. res.json(wrapper('success'));
  12. });
  13. router.get('/node/type/task/:projectId', (req, res) => {
  14. res.json(wrapper(
  15. Mock.mock({
  16. 'data|5-20': [{
  17. 'commits|3-5': [
  18. {
  19. gitlabUsername: Random.name(),
  20. id: 'string',
  21. message: 'string',
  22. timestamp: Random.datetime(),
  23. title: 'string',
  24. },
  25. ],
  26. deep: 1,
  27. description: Random.csentence(10, 40),
  28. endTime: Random.datetime(),
  29. 'id|+1': 1,
  30. leaf: false,
  31. parent: null,
  32. 'priority|1': ['紧急', '一般', '宽松'],
  33. processorId: 101,
  34. processorName: 'Jinyao',
  35. projectId: 101,
  36. startTime: Random.datetime(),
  37. 'state|1': ['已创建', '进行中', '已完成'],
  38. timeToTake: 10,
  39. title: Random.cname(),
  40. 'type|1': ['需求', '任务'],
  41. }],
  42. }).data,
  43. ));
  44. });
  45. router.delete('/node/:nodeId', (req, res) => {
  46. res.json(wrapper('success'));
  47. });
  48. router.post('/subNode/:parentId', (req, res) => {
  49. res.json(wrapper('success'));
  50. });
  51. router.get('/:projectId', (req, res) => {
  52. res.json(wrapper(
  53. Mock.mock([{
  54. 'commits|0-10': [
  55. {
  56. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  57. 'id|+1': 101,
  58. message: 'git commit message',
  59. timestamp: Random.datetime(),
  60. title: 'titleeee',
  61. },
  62. ],
  63. deep: 1,
  64. description: Random.csentence(10, 40),
  65. endTime: Random.datetime(),
  66. id: 1,
  67. leaf: false,
  68. parent: null,
  69. 'priority|1': ['紧急', '一般', '宽松'],
  70. processorId: 101,
  71. processorName: 'Jinyao',
  72. projectId: 101,
  73. startTime: Random.datetime(),
  74. 'state|1': ['已创建', '进行中', '已完成'],
  75. timeToTake: 10,
  76. title: Random.cname(),
  77. 'type|1': ['需求', '任务'],
  78. },
  79. {
  80. 'commits|0-10': [
  81. {
  82. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  83. 'id|+1': 101,
  84. message: 'git commit message',
  85. timestamp: Random.datetime(),
  86. title: 'titleeee',
  87. },
  88. ],
  89. deep: 2,
  90. description: Random.csentence(10, 40),
  91. endTime: Random.datetime(),
  92. id: 2,
  93. leaf: false,
  94. parent: 1,
  95. 'priority|1': ['紧急', '一般', '宽松'],
  96. processorId: 101,
  97. processorName: 'Jinyao',
  98. projectId: 101,
  99. startTime: Random.datetime(),
  100. 'state|1': ['已创建', '进行中', '已完成'],
  101. timeToTake: 10,
  102. title: Random.cname(),
  103. 'type|1': ['需求', '任务'],
  104. },
  105. {
  106. 'commits|0-10': [
  107. {
  108. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  109. 'id|+1': 101,
  110. message: 'git commit message',
  111. timestamp: Random.datetime(),
  112. title: 'titleeee',
  113. },
  114. ],
  115. deep: 2,
  116. description: Random.csentence(10, 40),
  117. endTime: Random.datetime(),
  118. id: 3,
  119. leaf: false,
  120. parent: 1,
  121. 'priority|1': ['紧急', '一般', '宽松'],
  122. processorId: 101,
  123. processorName: 'Jinyao',
  124. projectId: 101,
  125. startTime: Random.datetime(),
  126. 'state|1': ['已创建', '进行中', '已完成'],
  127. timeToTake: 10,
  128. title: Random.cname(),
  129. 'type|1': ['需求', '任务'],
  130. },
  131. {
  132. 'commits|0-10': [
  133. {
  134. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  135. 'id|+1': 101,
  136. message: 'git commit message',
  137. timestamp: Random.datetime(),
  138. title: 'titleeee',
  139. },
  140. ],
  141. deep: 3,
  142. description: Random.csentence(10, 40),
  143. endTime: Random.datetime(),
  144. id: 4,
  145. leaf: false,
  146. parent: 3,
  147. 'priority|1': ['紧急', '一般', '宽松'],
  148. processorId: 101,
  149. processorName: 'Jinyao',
  150. projectId: 101,
  151. startTime: Random.datetime(),
  152. 'state|1': ['已创建', '进行中', '已完成'],
  153. timeToTake: 10,
  154. title: Random.cname(),
  155. 'type|1': ['需求', '任务'],
  156. },
  157. {
  158. 'commits|0-10': [
  159. {
  160. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  161. 'id|+1': 101,
  162. message: 'git commit message',
  163. timestamp: Random.datetime(),
  164. title: 'titleeee',
  165. },
  166. ],
  167. deep: 3,
  168. description: Random.csentence(10, 40),
  169. endTime: Random.datetime(),
  170. id: 5,
  171. leaf: false,
  172. parent: 3,
  173. 'priority|1': ['紧急', '一般', '宽松'],
  174. processorId: 101,
  175. processorName: 'Jinyao',
  176. projectId: 101,
  177. startTime: Random.datetime(),
  178. 'state|1': ['已创建', '进行中', '已完成'],
  179. timeToTake: 10,
  180. title: Random.cname(),
  181. 'type|1': ['需求', '任务'],
  182. },
  183. {
  184. 'commits|0-10': [
  185. {
  186. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  187. 'id|+1': 101,
  188. message: 'git commit message',
  189. timestamp: Random.datetime(),
  190. title: 'titleeee',
  191. },
  192. ],
  193. deep: 4,
  194. description: Random.csentence(10, 40),
  195. endTime: Random.datetime(),
  196. id: 6,
  197. leaf: false,
  198. parent: 5,
  199. 'priority|1': ['紧急', '一般', '宽松'],
  200. processorId: 101,
  201. processorName: 'Jinyao',
  202. projectId: 101,
  203. startTime: Random.datetime(),
  204. 'state|1': ['已创建', '进行中', '已完成'],
  205. timeToTake: 10,
  206. title: Random.cname(),
  207. 'type|1': ['需求', '任务'],
  208. },
  209. {
  210. 'commits|0-10': [
  211. {
  212. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  213. 'id|+1': 101,
  214. message: 'git commit message',
  215. timestamp: Random.datetime(),
  216. title: 'titleeee',
  217. },
  218. ],
  219. deep: 4,
  220. description: Random.csentence(10, 40),
  221. endTime: Random.datetime(),
  222. id: 7,
  223. leaf: false,
  224. parent: 5,
  225. 'priority|1': ['紧急', '一般', '宽松'],
  226. processorId: 101,
  227. processorName: 'Jinyao',
  228. projectId: 101,
  229. startTime: Random.datetime(),
  230. 'state|1': ['已创建', '进行中', '已完成'],
  231. timeToTake: 10,
  232. title: Random.cname(),
  233. 'type|1': ['需求', '任务'],
  234. },
  235. {
  236. 'commits|0-10': [
  237. {
  238. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  239. 'id|+1': 101,
  240. message: 'git commit message',
  241. timestamp: Random.datetime(),
  242. title: 'titleeee',
  243. },
  244. ],
  245. deep: 4,
  246. description: Random.csentence(10, 40),
  247. endTime: Random.datetime(),
  248. id: 8,
  249. leaf: false,
  250. parent: 5,
  251. 'priority|1': ['紧急', '一般', '宽松'],
  252. processorId: 101,
  253. processorName: 'Jinyao',
  254. projectId: 101,
  255. startTime: Random.datetime(),
  256. 'state|1': ['已创建', '进行中', '已完成'],
  257. timeToTake: 10,
  258. title: Random.cname(),
  259. 'type|1': ['需求', '任务'],
  260. },
  261. ]),
  262. ));
  263. });
  264. module.exports = router;