tree.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. deep: 1,
  56. description: Random.csentence(10, 40),
  57. endTime: Random.datetime(),
  58. id: 1,
  59. leaf: false,
  60. parentId: null,
  61. 'priority|1': ['紧急', '一般', '宽松'],
  62. processorId: 101,
  63. processorName: 'Jinyao',
  64. projectId: 101,
  65. startTime: '2021-5-14 20:39:21',
  66. state: '进行中',
  67. timeToTake: 10,
  68. title: '软件开发云系统',
  69. 'type|1': ['需求', '任务'],
  70. },
  71. {
  72. deep: 2,
  73. description: Random.csentence(10, 40),
  74. endTime: Random.datetime(),
  75. id: 2,
  76. leaf: false,
  77. parentId: 1,
  78. 'priority|1': ['紧急', '一般', '宽松'],
  79. processorId: 101,
  80. processorName: 'hkshu12',
  81. projectId: 101,
  82. startTime: Random.datetime(),
  83. state: '已创建',
  84. timeToTake: 10,
  85. title: '需求管理模块',
  86. 'type|1': ['需求', '任务'],
  87. },
  88. {
  89. deep: 2,
  90. description: Random.csentence(10, 40),
  91. endTime: Random.datetime(),
  92. id: 3,
  93. leaf: false,
  94. parentId: 1,
  95. 'priority|1': ['紧急', '一般', '宽松'],
  96. processorId: 101,
  97. processorName: 'Jinyao',
  98. projectId: 101,
  99. startTime: '2021-5-14 20:39:21',
  100. 'state|1': ['已创建', '进行中', '已完成'],
  101. timeToTake: 10,
  102. title: '项目管理模块',
  103. 'type|1': ['需求', '任务'],
  104. },
  105. {
  106. deep: 3,
  107. description: '这是需求4。',
  108. endTime: '',
  109. id: 4,
  110. leaf: false,
  111. parentId: 3,
  112. 'priority|1': ['紧急', '一般', '宽松'],
  113. processorId: 101,
  114. processorName: 'Jinyao',
  115. projectId: 101,
  116. startTime: '2021-5-14 20:39:21',
  117. state: '已创建',
  118. timeToTake: 10,
  119. title: '成员管理',
  120. 'type|1': ['需求', '任务'],
  121. },
  122. {
  123. deep: 3,
  124. description: Random.csentence(10, 40),
  125. endTime: Random.datetime(),
  126. id: 5,
  127. leaf: false,
  128. parentId: 3,
  129. 'priority|1': ['紧急', '一般', '宽松'],
  130. processorId: 101,
  131. processorName: 'Jinyao',
  132. projectId: 101,
  133. startTime: '2021-5-14 20:39:21',
  134. 'state|1': ['已创建', '进行中', '已完成'],
  135. timeToTake: 10,
  136. title: '项目管理',
  137. 'type|1': ['需求', '任务'],
  138. },
  139. {
  140. deep: 4,
  141. description: Random.csentence(10, 40),
  142. endTime: Random.datetime(),
  143. id: 6,
  144. leaf: false,
  145. parentId: 5,
  146. 'priority|1': ['紧急', '一般', '宽松'],
  147. processorId: 101,
  148. processorName: 'Jinyao',
  149. projectId: 101,
  150. startTime: '2021-5-14 20:39:21',
  151. state: '已创建',
  152. timeToTake: 10,
  153. title: '创建项目',
  154. 'type|1': ['任务'],
  155. },
  156. {
  157. deep: 4,
  158. description: Random.csentence(10, 40),
  159. endTime: Random.datetime(),
  160. id: 7,
  161. leaf: false,
  162. parentId: 5,
  163. 'priority|1': ['紧急', '一般', '宽松'],
  164. processorId: 101,
  165. processorName: 'Jinyao',
  166. projectId: 101,
  167. startTime: '2021-5-14 20:39:21',
  168. state: '进行中',
  169. timeToTake: 10,
  170. title: '获取项目列表',
  171. 'type|1': ['任务'],
  172. },
  173. {
  174. deep: 4,
  175. description: Random.csentence(10, 40),
  176. endTime: Random.datetime(),
  177. id: 8,
  178. leaf: false,
  179. parentId: 5,
  180. 'priority|1': ['紧急', '一般', '宽松'],
  181. processorId: 101,
  182. processorName: 'Jinyao',
  183. projectId: 101,
  184. startTime: Random.datetime(),
  185. state: '已完成',
  186. timeToTake: 10,
  187. title: '添加关联项目',
  188. 'type|1': ['任务'],
  189. },
  190. {
  191. deep: 3,
  192. description: '提供需求管理能力,包括增删改查功能',
  193. endTime: '',
  194. id: 9,
  195. leaf: false,
  196. parentId: 2,
  197. 'priority|1': ['紧急', '一般', '宽松'],
  198. processorId: 101,
  199. processorName: 'hkshu12',
  200. projectId: 101,
  201. startTime: '2021-5-14 20:39:21',
  202. state: '已创建',
  203. timeToTake: 10,
  204. title: '需求管理',
  205. 'type|1': ['需求', '任务'],
  206. },
  207. {
  208. deep: 3,
  209. description: Random.csentence(10, 40),
  210. endTime: Random.datetime(),
  211. id: 11,
  212. leaf: false,
  213. parentId: 2,
  214. 'priority|1': ['紧急', '一般', '宽松'],
  215. processorId: 101,
  216. processorName: 'hkshu12',
  217. projectId: 101,
  218. startTime: '2021-5-14 20:39:21',
  219. state: '已创建',
  220. timeToTake: 10,
  221. title: '需求树展示',
  222. 'type|1': ['需求'],
  223. },
  224. {
  225. deep: 4,
  226. description: Random.csentence(10, 40),
  227. endTime: Random.datetime(),
  228. id: 12,
  229. leaf: false,
  230. parentId: 9,
  231. 'priority|1': ['紧急', '一般', '宽松'],
  232. processorId: 101,
  233. processorName: 'hkshu12',
  234. projectId: 101,
  235. startTime: '2021-5-14 20:39:21',
  236. state: '已创建',
  237. timeToTake: 10,
  238. title: '需求增删改查',
  239. 'type|1': ['任务'],
  240. },
  241. {
  242. deep: 4,
  243. description: Random.csentence(10, 40),
  244. endTime: Random.datetime(),
  245. id: 13,
  246. leaf: false,
  247. parentId: 11,
  248. 'priority|1': ['紧急', '一般', '宽松'],
  249. processorId: 101,
  250. processorName: 'hkshu12',
  251. projectId: 101,
  252. startTime: '2021-5-14 20:39:21',
  253. state: '已创建',
  254. timeToTake: 10,
  255. title: '需求树可视化',
  256. 'type|1': ['任务'],
  257. },
  258. {
  259. deep: 4,
  260. description: Random.csentence(10, 40),
  261. endTime: Random.datetime(),
  262. id: 14,
  263. leaf: false,
  264. parentId: 4,
  265. 'priority|1': ['紧急', '一般', '宽松'],
  266. processorId: 101,
  267. processorName: 'hkshu12',
  268. projectId: 101,
  269. startTime: '2021-5-14 20:39:21',
  270. state: '已创建',
  271. timeToTake: 10,
  272. title: '邀请成员加入项目',
  273. 'type|1': ['任务'],
  274. },
  275. {
  276. deep: 4,
  277. description: Random.csentence(10, 40),
  278. endTime: Random.datetime(),
  279. id: 15,
  280. leaf: false,
  281. parentId: 9,
  282. 'priority|1': ['紧急', '一般', '宽松'],
  283. processorId: 101,
  284. processorName: 'hkshu12',
  285. projectId: 101,
  286. startTime: '2021-5-14 20:39:21',
  287. state: '已创建',
  288. timeToTake: 10,
  289. title: '这是一个新建的子节点',
  290. 'type|1': ['任务'],
  291. },
  292. ]),
  293. ));
  294. });
  295. module.exports = router;