tree.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. parentId: 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. {
  55. 'commits|0-10': [
  56. {
  57. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  58. 'id|+1': 101,
  59. message: 'git commit message',
  60. timestamp: Random.datetime(),
  61. title: 'titleeee',
  62. },
  63. ],
  64. deep: 2,
  65. description: Random.csentence(10, 40),
  66. endTime: Random.datetime(),
  67. id: 3,
  68. leaf: false,
  69. parentId: 1,
  70. 'priority|1': ['紧急', '一般', '宽松'],
  71. processorId: 101,
  72. processorName: 'Jinyao',
  73. projectId: 101,
  74. startTime: Random.datetime(),
  75. 'state|1': ['已创建', '进行中', '已完成'],
  76. timeToTake: 10,
  77. title: Random.cname(),
  78. 'type|1': ['需求', '任务'],
  79. },
  80. {
  81. 'commits|0-10': [
  82. {
  83. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  84. 'id|+1': 101,
  85. message: 'git commit message',
  86. timestamp: Random.datetime(),
  87. title: 'titleeee',
  88. },
  89. ],
  90. deep: 3,
  91. description: Random.csentence(10, 40),
  92. endTime: Random.datetime(),
  93. id: 9,
  94. leaf: false,
  95. parentId: 2,
  96. 'priority|1': ['紧急', '一般', '宽松'],
  97. processorId: 101,
  98. processorName: 'Jinyao',
  99. projectId: 101,
  100. startTime: Random.datetime(),
  101. 'state|1': ['已创建', '进行中', '已完成'],
  102. timeToTake: 10,
  103. title: Random.cname(),
  104. 'type|1': ['需求', '任务'],
  105. },
  106. {
  107. 'commits|0-10': [
  108. {
  109. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  110. 'id|+1': 101,
  111. message: 'git commit message',
  112. timestamp: Random.datetime(),
  113. title: 'titleeee',
  114. },
  115. ],
  116. deep: 3,
  117. description: Random.csentence(10, 40),
  118. endTime: Random.datetime(),
  119. id: 10,
  120. leaf: false,
  121. parentId: 2,
  122. 'priority|1': ['紧急', '一般', '宽松'],
  123. processorId: 101,
  124. processorName: 'Jinyao',
  125. projectId: 101,
  126. startTime: Random.datetime(),
  127. 'state|1': ['已创建', '进行中', '已完成'],
  128. timeToTake: 10,
  129. title: Random.cname(),
  130. 'type|1': ['需求', '任务'],
  131. },
  132. {
  133. 'commits|0-10': [
  134. {
  135. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  136. 'id|+1': 101,
  137. message: 'git commit message',
  138. timestamp: Random.datetime(),
  139. title: 'titleeee',
  140. },
  141. ],
  142. deep: 4,
  143. description: Random.csentence(10, 40),
  144. endTime: Random.datetime(),
  145. id: 6,
  146. leaf: false,
  147. parentId: 5,
  148. 'priority|1': ['紧急', '一般', '宽松'],
  149. processorId: 101,
  150. processorName: 'Jinyao',
  151. projectId: 101,
  152. startTime: Random.datetime(),
  153. 'state|1': ['已创建', '进行中', '已完成'],
  154. timeToTake: 10,
  155. title: Random.cname(),
  156. 'type|1': ['需求', '任务'],
  157. },
  158. {
  159. 'commits|0-10': [
  160. {
  161. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  162. 'id|+1': 101,
  163. message: 'git commit message',
  164. timestamp: Random.datetime(),
  165. title: 'titleeee',
  166. },
  167. ],
  168. deep: 3,
  169. description: Random.csentence(10, 40),
  170. endTime: Random.datetime(),
  171. id: 4,
  172. leaf: false,
  173. parentId: 3,
  174. 'priority|1': ['紧急', '一般', '宽松'],
  175. processorId: 101,
  176. processorName: 'Jinyao',
  177. projectId: 101,
  178. startTime: Random.datetime(),
  179. 'state|1': ['已创建', '进行中', '已完成'],
  180. timeToTake: 10,
  181. title: Random.cname(),
  182. 'type|1': ['需求', '任务'],
  183. },
  184. {
  185. 'commits|0-10': [
  186. {
  187. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  188. 'id|+1': 101,
  189. message: 'git commit message',
  190. timestamp: Random.datetime(),
  191. title: 'titleeee',
  192. },
  193. ],
  194. deep: 1,
  195. description: Random.csentence(10, 40),
  196. endTime: Random.datetime(),
  197. id: 1,
  198. leaf: false,
  199. parentId: null,
  200. 'priority|1': ['紧急', '一般', '宽松'],
  201. processorId: 101,
  202. processorName: 'Jinyao',
  203. projectId: 101,
  204. startTime: Random.datetime(),
  205. 'state|1': ['已创建', '进行中', '已完成'],
  206. timeToTake: 10,
  207. title: Random.cname(),
  208. 'type|1': ['需求', '任务'],
  209. },
  210. {
  211. 'commits|0-10': [
  212. {
  213. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  214. 'id|+1': 101,
  215. message: 'git commit message',
  216. timestamp: Random.datetime(),
  217. title: 'titleeee',
  218. },
  219. ],
  220. deep: 3,
  221. description: Random.csentence(10, 40),
  222. endTime: Random.datetime(),
  223. id: 5,
  224. leaf: false,
  225. parentId: 3,
  226. 'priority|1': ['紧急', '一般', '宽松'],
  227. processorId: 101,
  228. processorName: 'Jinyao',
  229. projectId: 101,
  230. startTime: Random.datetime(),
  231. 'state|1': ['已创建', '进行中', '已完成'],
  232. timeToTake: 10,
  233. title: Random.cname(),
  234. 'type|1': ['需求', '任务'],
  235. },
  236. {
  237. 'commits|0-10': [
  238. {
  239. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  240. 'id|+1': 101,
  241. message: 'git commit message',
  242. timestamp: Random.datetime(),
  243. title: 'titleeee',
  244. },
  245. ],
  246. deep: 2,
  247. description: Random.csentence(10, 40),
  248. endTime: Random.datetime(),
  249. id: 2,
  250. leaf: false,
  251. parentId: 1,
  252. 'priority|1': ['紧急', '一般', '宽松'],
  253. processorId: 101,
  254. processorName: 'Jinyao',
  255. projectId: 101,
  256. startTime: Random.datetime(),
  257. 'state|1': ['已创建', '进行中', '已完成'],
  258. timeToTake: 10,
  259. title: Random.cname(),
  260. 'type|1': ['需求', '任务'],
  261. },
  262. {
  263. 'commits|0-10': [
  264. {
  265. 'gitlabUsername|1': ['hks', 'wph', 'zxr', 'cyt'],
  266. 'id|+1': 101,
  267. message: 'git commit message',
  268. timestamp: Random.datetime(),
  269. title: 'titleeee',
  270. },
  271. ],
  272. deep: 4,
  273. description: Random.csentence(10, 40),
  274. endTime: Random.datetime(),
  275. id: 7,
  276. leaf: false,
  277. parentId: 5,
  278. 'priority|1': ['紧急', '一般', '宽松'],
  279. processorId: 101,
  280. processorName: 'Jinyao',
  281. projectId: 101,
  282. startTime: Random.datetime(),
  283. 'state|1': ['已创建', '进行中', '已完成'],
  284. timeToTake: 10,
  285. title: Random.cname(),
  286. 'type|1': ['需求', '任务'],
  287. },
  288. {
  289. deep: 4,
  290. description: Random.csentence(10, 40),
  291. endTime: Random.datetime(),
  292. id: 8,
  293. leaf: false,
  294. parentId: 5,
  295. 'priority|1': ['紧急', '一般', '宽松'],
  296. processorId: 101,
  297. processorName: 'Jinyao',
  298. projectId: 101,
  299. startTime: Random.datetime(),
  300. 'state|1': ['已创建', '进行中', '已完成'],
  301. timeToTake: 10,
  302. title: Random.cname(),
  303. 'type|1': ['需求', '任务'],
  304. },
  305. ]),
  306. ));
  307. });
  308. module.exports = router;