initSystemData.service.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. import { Provide } from '@midwayjs/core';
  2. import { InjectDataSource, InjectEntityModel } from '@midwayjs/typeorm';
  3. import { DataSource, Repository } from 'typeorm';
  4. import { Menus } from '../../entity/system/menus.entity';
  5. import { cloneDeep, get } from 'lodash';
  6. import { Role } from '../../entity/system/role.entity';
  7. import { UserMenus } from '../../entity/system/userMenus.entity';
  8. @Provide()
  9. export class InitSystemDataService {
  10. @InjectEntityModel(Menus)
  11. Menus: Repository<Menus>;
  12. @InjectEntityModel(Role)
  13. Role: Repository<Role>;
  14. @InjectEntityModel(UserMenus)
  15. UserMenus: Repository<UserMenus>;
  16. @InjectDataSource('default')
  17. defaultDataSource: DataSource;
  18. /**初始化角色的菜单(不包含管理员) */
  19. async initRoleMenus() {
  20. const builder = this.Role.createQueryBuilder().update(Role);
  21. /**共有: 基础信息,认证信息,行业动态 */
  22. const common = ['center_basic', 'center_attestation', 'center_notice', 'center_collection', 'center_password', 'center_sign'];
  23. // 只用通用菜单的角色
  24. const justCommonRole = ['User', 'Association', 'Investment', 'State'];
  25. await builder.set({ menu: common }).where('code IN (:...value)', { value: justCommonRole }).execute();
  26. // 第一类菜单
  27. const menus1 = [...common, 'center_news2', 'center_demand', 'center_supply', 'center_achievement', 'center_project', 'center_footplate', 'center_service'];
  28. // 第一类菜单用户: 用户,科研机构,孵化基地,企业,高校
  29. const roleUseMenus1 = ['Expert', 'Unit', 'Incubator', 'Company', 'YX'];
  30. await builder.set({ menu: menus1 }).where('code IN (:...value)', { value: roleUseMenus1 }).execute();
  31. // 创业大赛用户: 需要去掉报名管理,加入赛事管理
  32. const MatchRole = common.filter(f => f !== 'center_sign');
  33. MatchRole.push('center_match');
  34. await builder
  35. .set({ menu: MatchRole })
  36. .where('code IN (:...value)', { value: ['Competition'] })
  37. .execute();
  38. }
  39. /**初始化角色数据 */
  40. async initRoleData() {
  41. await this.clearTable(get(this.Role, 'metadata.givenTableName'));
  42. const datas: any = [
  43. {
  44. code: 'Admin',
  45. name: '管理员',
  46. menu: ['home'],
  47. is_use: '0',
  48. is_default: '0',
  49. is_admin_role: '1',
  50. },
  51. {
  52. code: 'User',
  53. name: '普通用户',
  54. is_use: '0',
  55. is_default: '0',
  56. is_admin_role: '0',
  57. },
  58. {
  59. code: 'Expert',
  60. name: '专家',
  61. is_use: '0',
  62. is_default: '0',
  63. is_admin_role: '0',
  64. },
  65. {
  66. code: 'Company',
  67. name: '企业',
  68. is_use: '0',
  69. is_default: '0',
  70. is_admin_role: '0',
  71. },
  72. {
  73. code: 'Unit',
  74. name: '科研机构',
  75. is_use: '0',
  76. is_default: '0',
  77. is_admin_role: '0',
  78. },
  79. {
  80. code: 'Incubator',
  81. name: '孵化基地',
  82. is_use: '0',
  83. is_default: '0',
  84. is_admin_role: '0',
  85. },
  86. {
  87. code: 'Competition',
  88. name: '创业大赛',
  89. is_use: '0',
  90. is_default: '0',
  91. is_admin_role: '0',
  92. },
  93. {
  94. code: 'Association',
  95. name: '商协会',
  96. is_use: '0',
  97. is_default: '0',
  98. is_admin_role: '0',
  99. },
  100. {
  101. code: 'School',
  102. name: '院校',
  103. is_use: '0',
  104. is_default: '0',
  105. is_admin_role: '0',
  106. },
  107. {
  108. code: 'State',
  109. name: '政府部门',
  110. is_use: '0',
  111. is_default: '0',
  112. is_admin_role: '0',
  113. },
  114. {
  115. code: 'Investment',
  116. name: '投资人',
  117. is_use: '0',
  118. is_default: '0',
  119. is_admin_role: '0',
  120. },
  121. ];
  122. for (let i = 0; i < datas.length; i++) {
  123. const e = datas[i];
  124. e.id = i + 1;
  125. }
  126. await this.Role.insert(datas);
  127. }
  128. /**初始化用户目录 */
  129. async initUserMenus() {
  130. await this.clearTable(get(this.UserMenus, 'metadata.givenTableName'));
  131. const datas = [
  132. {
  133. order_num: 0,
  134. name: '基础信息',
  135. route_name: 'center_basic',
  136. i18n_code: 'menus.center_basic',
  137. path: '/center/basic',
  138. component: '/center/basic',
  139. type: '1',
  140. config: [],
  141. is_default: '0',
  142. is_use: '0',
  143. icon: 'User',
  144. },
  145. {
  146. order_num: 1,
  147. name: '认证入驻',
  148. route_name: 'center_attestation',
  149. i18n_code: 'menus.center_attestation',
  150. path: '/center/attestation',
  151. component: '/center/attestation',
  152. type: '1',
  153. config: [],
  154. is_default: '0',
  155. is_use: '0',
  156. icon: 'Finished',
  157. },
  158. {
  159. order_num: 2,
  160. name: '通知管理',
  161. route_name: 'center_notice',
  162. i18n_code: 'menus.center_notice',
  163. path: '/center/notice',
  164. component: '/center/notice',
  165. type: '1',
  166. config: [],
  167. is_default: '0',
  168. is_use: '0',
  169. icon: 'Notebook',
  170. },
  171. {
  172. order_num: 3,
  173. name: '行业动态',
  174. route_name: 'center_news2',
  175. i18n_code: 'menus.center_news2',
  176. path: '/center/news2',
  177. component: '/center/news2',
  178. type: '1',
  179. config: [],
  180. is_default: '0',
  181. is_use: '0',
  182. icon: 'Message',
  183. },
  184. {
  185. order_num: 4,
  186. name: '需求管理',
  187. route_name: 'center_demand',
  188. i18n_code: 'menus.center_demand',
  189. path: '/center/demand',
  190. component: '/center/demand',
  191. type: '1',
  192. config: [],
  193. is_default: '0',
  194. is_use: '0',
  195. icon: 'DataBoard',
  196. },
  197. {
  198. order_num: 5,
  199. name: '供给管理',
  200. route_name: 'center_supply',
  201. i18n_code: 'menus.center_supply',
  202. path: '/center/supply',
  203. component: '/center/supply',
  204. type: '1',
  205. config: [],
  206. is_default: '0',
  207. is_use: '0',
  208. icon: 'Notification',
  209. },
  210. {
  211. order_num: 6,
  212. name: '成果管理',
  213. route_name: 'center_achievement',
  214. i18n_code: 'menus.center_achievement',
  215. path: '/center/achievement',
  216. component: '/center/achievement',
  217. type: '1',
  218. config: [],
  219. is_default: '0',
  220. is_use: '0',
  221. icon: 'Medal',
  222. },
  223. {
  224. order_num: 7,
  225. name: '项目管理',
  226. route_name: 'center_project',
  227. i18n_code: 'menus.center_project',
  228. path: '/center/project',
  229. component: '/center/project',
  230. type: '1',
  231. config: [],
  232. is_default: '0',
  233. is_use: '0',
  234. icon: 'Trophy',
  235. },
  236. {
  237. order_num: 8,
  238. name: '中试管理',
  239. route_name: 'center_footplate',
  240. i18n_code: 'menus.center_footplate',
  241. path: '/center/footplate',
  242. component: '/center/footplate',
  243. type: '1',
  244. config: [],
  245. is_default: '0',
  246. is_use: '0',
  247. icon: 'TakeawayBox',
  248. },
  249. {
  250. order_num: 9,
  251. name: '服务管理',
  252. route_name: 'center_service',
  253. i18n_code: 'menus.center_service',
  254. path: '/center/service',
  255. component: '/center/service',
  256. type: '1',
  257. config: [],
  258. is_default: '0',
  259. is_use: '0',
  260. icon: 'TakeawayBox',
  261. },
  262. {
  263. order_num: 10,
  264. name: '赛事管理',
  265. route_name: 'center_match',
  266. i18n_code: 'menus.center_match',
  267. path: '/center/match',
  268. component: '/center/match',
  269. type: '1',
  270. config: [],
  271. is_default: '0',
  272. is_use: '0',
  273. icon: 'CollectionTag',
  274. },
  275. {
  276. order_num: 11,
  277. name: '活动管理',
  278. route_name: 'center_sign',
  279. i18n_code: 'menus.center_sign',
  280. path: '/center/sign',
  281. component: '/center/sign',
  282. type: '1',
  283. config: [],
  284. is_default: '0',
  285. is_use: '0',
  286. icon: 'Suitcase',
  287. },
  288. {
  289. order_num: 12,
  290. name: '产研行研',
  291. route_name: 'center_journal',
  292. i18n_code: 'menus.center_journal',
  293. path: '/center/journal',
  294. component: '/center/journal',
  295. type: '1',
  296. config: [],
  297. is_default: '0',
  298. is_use: '0',
  299. icon: 'Reading',
  300. },
  301. {
  302. order_num: 13,
  303. name: '企业选择',
  304. route_name: 'center_company',
  305. i18n_code: 'menus.center_company',
  306. path: '/center/company',
  307. component: '/center/company',
  308. type: '1',
  309. config: [],
  310. is_default: '0',
  311. is_use: '0',
  312. icon: 'SwitchFilled',
  313. },
  314. {
  315. order_num: 998,
  316. name: '我的收藏',
  317. route_name: 'center_collection',
  318. i18n_code: 'menus.center_collection',
  319. path: '/center/collection',
  320. component: '/center/collection',
  321. type: '1',
  322. config: [],
  323. is_default: '0',
  324. is_use: '0',
  325. icon: 'Collection',
  326. },
  327. {
  328. order_num: 999,
  329. name: '修改密码',
  330. route_name: 'center_password',
  331. i18n_code: 'menus.center_password',
  332. path: '/center/password',
  333. component: '/center/password',
  334. type: '1',
  335. config: [],
  336. is_default: '0',
  337. is_use: '0',
  338. icon: 'Lock',
  339. },
  340. ];
  341. await this.UserMenus.insert(datas);
  342. }
  343. /**初始化后台目录 */
  344. async initSystemMenus() {
  345. await this.clearTable(get(this.Menus, 'metadata.givenTableName'));
  346. const datas: any = [
  347. {
  348. name: '首页',
  349. path: '/',
  350. type: '1',
  351. is_default: '0',
  352. is_use: '0',
  353. route_name: 'home',
  354. },
  355. {
  356. name: '系统管理',
  357. path: '/system/index',
  358. type: '1',
  359. is_default: '0',
  360. is_use: '0',
  361. route_name: 'system',
  362. children: [
  363. {
  364. name: '管理员目录',
  365. component: 'admin-menus',
  366. type: '2',
  367. is_default: '0',
  368. is_use: '0',
  369. route_name: 'system_admin_menus',
  370. },
  371. {
  372. name: '用户目录',
  373. component: 'user-menus',
  374. type: '2',
  375. is_default: '0',
  376. is_use: '0',
  377. route_name: 'system_user_menus',
  378. },
  379. {
  380. name: '字典管理',
  381. component: 'dict',
  382. type: '2',
  383. is_default: '0',
  384. is_use: '0',
  385. route_name: 'system_dict',
  386. },
  387. {
  388. name: '地区管理',
  389. component: 'region',
  390. type: '2',
  391. is_default: '0',
  392. is_use: '0',
  393. route_name: 'system_region',
  394. },
  395. {
  396. name: '系统功能重置',
  397. component: 'system-func',
  398. type: '2',
  399. is_default: '0',
  400. is_use: '0',
  401. route_name: 'system_func',
  402. },
  403. ],
  404. },
  405. {
  406. name: '平台设置',
  407. path: '/platform/index',
  408. type: '1',
  409. is_default: '0',
  410. is_use: '0',
  411. route_name: 'platform',
  412. children: [
  413. {
  414. name: '基础设置',
  415. component: 'basic',
  416. type: '2',
  417. is_default: '0',
  418. is_use: '0',
  419. route_name: 'platform_basic',
  420. },
  421. {
  422. name: '部门管理',
  423. component: 'dept',
  424. type: '2',
  425. is_default: '0',
  426. is_use: '0',
  427. route_name: 'platform_dept',
  428. },
  429. {
  430. name: '角色管理',
  431. component: 'role',
  432. type: '2',
  433. is_default: '0',
  434. is_use: '0',
  435. route_name: 'platform_role',
  436. },
  437. {
  438. name: '标签管理',
  439. component: 'tags',
  440. type: '2',
  441. is_default: '0',
  442. is_use: '0',
  443. route_name: 'platform_tags',
  444. },
  445. {
  446. name: '产业管理',
  447. component: 'sector',
  448. type: '2',
  449. is_default: '0',
  450. is_use: '0',
  451. route_name: 'platform_sector',
  452. },
  453. {
  454. name: '合作伙伴',
  455. component: 'friend',
  456. type: '2',
  457. is_default: '0',
  458. is_use: '0',
  459. route_name: 'platform_friend',
  460. },
  461. {
  462. name: '导入数据',
  463. component: 'import',
  464. type: '2',
  465. is_default: '0',
  466. is_use: '0',
  467. route_name: 'platform_import',
  468. },
  469. ],
  470. },
  471. {
  472. name: '信息管理',
  473. path: '/information/index',
  474. type: '1',
  475. is_default: '0',
  476. is_use: '0',
  477. route_name: 'information',
  478. children: [
  479. {
  480. name: '平台数据',
  481. component: 'platform',
  482. type: '2',
  483. is_default: '0',
  484. is_use: '0',
  485. route_name: 'information_platform',
  486. children: [
  487. {
  488. name: '供给信息',
  489. component: 'supply',
  490. type: '2',
  491. is_default: '0',
  492. is_use: '0',
  493. route_name: 'information_platform_supply',
  494. },
  495. {
  496. name: '需求信息',
  497. component: 'demand',
  498. type: '2',
  499. is_default: '0',
  500. is_use: '0',
  501. route_name: 'information_platform_demand',
  502. },
  503. {
  504. name: '技术成果',
  505. component: 'achievement',
  506. type: '2',
  507. is_default: '0',
  508. is_use: '0',
  509. route_name: 'information_platform_achievement',
  510. },
  511. {
  512. name: '双创活动',
  513. component: 'match',
  514. type: '2',
  515. is_default: '0',
  516. is_use: '0',
  517. route_name: 'information_platform_match',
  518. },
  519. {
  520. name: '项目信息',
  521. component: 'project',
  522. type: '2',
  523. is_default: '0',
  524. is_use: '0',
  525. route_name: 'information_platform_project',
  526. },
  527. {
  528. name: '中试信息',
  529. component: 'footplate',
  530. type: '2',
  531. is_default: '0',
  532. is_use: '0',
  533. route_name: 'information_platform_footplate',
  534. },
  535. {
  536. name: '服务支撑',
  537. component: 'support',
  538. type: '2',
  539. is_default: '0',
  540. is_use: '0',
  541. route_name: 'information_platform_support',
  542. },
  543. ],
  544. },
  545. {
  546. name: '角色数据',
  547. component: 'role',
  548. type: '2',
  549. is_default: '0',
  550. is_use: '0',
  551. route_name: 'information_role',
  552. children: [
  553. {
  554. name: '创业大赛',
  555. component: 'competition',
  556. type: '2',
  557. is_default: '0',
  558. is_use: '0',
  559. route_name: 'information_role_competition',
  560. },
  561. {
  562. name: '投资人',
  563. component: 'investment',
  564. type: '2',
  565. is_default: '0',
  566. is_use: '0',
  567. route_name: 'information_role_investment',
  568. },
  569. {
  570. name: '商协会',
  571. component: 'association',
  572. type: '2',
  573. is_default: '0',
  574. is_use: '0',
  575. route_name: 'information_role_association',
  576. },
  577. {
  578. name: '政府部门',
  579. component: 'state',
  580. type: '2',
  581. is_default: '0',
  582. is_use: '0',
  583. route_name: 'information_role_state',
  584. },
  585. {
  586. name: '院校',
  587. component: 'school',
  588. type: '2',
  589. is_default: '0',
  590. is_use: '0',
  591. route_name: 'information_role_school',
  592. },
  593. {
  594. name: '企业',
  595. component: 'company',
  596. type: '2',
  597. is_default: '0',
  598. is_use: '0',
  599. route_name: 'information_role_company',
  600. },
  601. {
  602. name: '专家',
  603. component: 'expert',
  604. type: '2',
  605. is_default: '0',
  606. is_use: '0',
  607. route_name: 'information_role_expert',
  608. },
  609. {
  610. name: '科研机构',
  611. component: 'unit',
  612. type: '2',
  613. is_default: '0',
  614. is_use: '0',
  615. route_name: 'information_role_unit',
  616. },
  617. {
  618. name: '孵化基地',
  619. component: 'incubator',
  620. type: '2',
  621. is_default: '0',
  622. is_use: '0',
  623. route_name: 'information_role_incubator',
  624. },
  625. ],
  626. },
  627. {
  628. name: '平台新闻',
  629. component: 'news',
  630. type: '2',
  631. is_default: '0',
  632. is_use: '0',
  633. route_name: 'information_news',
  634. children: [
  635. {
  636. name: '政策信息',
  637. component: 'policy',
  638. type: '2',
  639. is_default: '0',
  640. is_use: '0',
  641. route_name: 'information_news_policy',
  642. },
  643. {
  644. name: '新闻通知',
  645. component: 'news',
  646. type: '2',
  647. is_default: '0',
  648. is_use: '0',
  649. route_name: 'information_news_news',
  650. },
  651. {
  652. name: '行业动态',
  653. component: 'trends',
  654. type: '2',
  655. is_default: '0',
  656. is_use: '0',
  657. route_name: 'information_news_trends',
  658. },
  659. ],
  660. },
  661. ],
  662. },
  663. {
  664. name: '行研产研',
  665. path: '/journal/index',
  666. type: '1',
  667. is_default: '0',
  668. is_use: '0',
  669. route_name: 'journal',
  670. },
  671. {
  672. name: '用户管理',
  673. path: '/user/index',
  674. type: '1',
  675. is_default: '0',
  676. is_use: '0',
  677. route_name: 'user',
  678. children: [
  679. {
  680. name: '管理员用户',
  681. component: 'admin',
  682. type: '2',
  683. is_default: '0',
  684. is_use: '0',
  685. route_name: 'user_admin',
  686. },
  687. {
  688. name: '平台用户',
  689. component: 'user',
  690. type: '2',
  691. is_default: '0',
  692. is_use: '0',
  693. route_name: 'user_user',
  694. },
  695. ],
  696. },
  697. {
  698. name: '审核管理',
  699. path: '/exam/index',
  700. type: '1',
  701. is_default: '0',
  702. is_use: '0',
  703. route_name: 'exam',
  704. children: [
  705. {
  706. name: '审核设置',
  707. component: 'setting',
  708. type: '2',
  709. is_default: '0',
  710. is_use: '0',
  711. route_name: 'exam_setting',
  712. },
  713. {
  714. name: '联系申请',
  715. component: 'contact',
  716. type: '2',
  717. is_default: '0',
  718. is_use: '0',
  719. route_name: 'exam_contact_apply',
  720. },
  721. {
  722. name: '企业认领',
  723. component: 'company',
  724. type: '2',
  725. is_default: '0',
  726. is_use: '0',
  727. route_name: 'exam_company',
  728. },
  729. ],
  730. },
  731. {
  732. name: '数据看板',
  733. path: '/board/index',
  734. type: '1',
  735. is_default: '0',
  736. is_use: '0',
  737. route_name: 'board',
  738. children: [
  739. {
  740. name: '企业',
  741. component: 'company',
  742. type: '2',
  743. is_default: '0',
  744. is_use: '0',
  745. route_name: 'board_company',
  746. },
  747. {
  748. name: '专家',
  749. component: 'expert',
  750. type: '2',
  751. is_default: '0',
  752. is_use: '0',
  753. route_name: 'board_expert',
  754. },
  755. {
  756. name: '需求',
  757. component: 'demand',
  758. type: '2',
  759. is_default: '0',
  760. is_use: '0',
  761. route_name: 'board_demand',
  762. },
  763. {
  764. name: '供给',
  765. component: 'supply',
  766. type: '2',
  767. is_default: '0',
  768. is_use: '0',
  769. route_name: 'board_supply',
  770. },
  771. {
  772. name: '成果',
  773. component: 'achievement',
  774. type: '2',
  775. is_default: '0',
  776. is_use: '0',
  777. route_name: 'board_achievement',
  778. },
  779. {
  780. name: '项目',
  781. component: 'project',
  782. type: '2',
  783. is_default: '0',
  784. is_use: '0',
  785. route_name: 'board_project',
  786. },
  787. {
  788. name: '孵化基地',
  789. component: 'incubate',
  790. type: '2',
  791. is_default: '0',
  792. is_use: '0',
  793. route_name: 'board_incubate',
  794. },
  795. {
  796. name: '用户数据',
  797. component: 'user',
  798. type: '2',
  799. is_default: '0',
  800. is_use: '0',
  801. route_name: 'board_user',
  802. },
  803. ],
  804. },
  805. {
  806. name: '站内消息',
  807. order_num: 998,
  808. path: '/message/index',
  809. type: '1',
  810. is_default: '0',
  811. is_use: '0',
  812. route_name: 'message',
  813. },
  814. {
  815. name: '日志管理',
  816. order_num: 999,
  817. path: '/log/index',
  818. type: '1',
  819. is_default: '0',
  820. is_use: '0',
  821. route_name: 'log',
  822. },
  823. ];
  824. // 声明每个数据id.降维并带上父级id
  825. // 递归处理
  826. let id = 1;
  827. const deepDeal = (list, parent_id?) => {
  828. const result = [];
  829. for (let i = 0; i < list.length; i++) {
  830. const d = list[i];
  831. // 补充id和order_num和parent_id
  832. d.id = cloneDeep(id);
  833. id = id + 1;
  834. if (!get(d, 'order_num')) d.order_num = i + 1;
  835. if (parent_id) {
  836. // 有上级id,则一定是子页面
  837. d.parent_id = parent_id;
  838. d.type = '2';
  839. }
  840. let children = get(d, 'children');
  841. const cd = cloneDeep(d);
  842. delete cd.children;
  843. result.push(cd);
  844. if (!children) continue;
  845. children = deepDeal(children, d.id);
  846. result.push(...children);
  847. }
  848. return result;
  849. };
  850. const odDatas = deepDeal(datas);
  851. await this.Menus.insert(odDatas);
  852. }
  853. /**
  854. * 清空表与id序列
  855. * @param tableName 表名 小驼峰
  856. */
  857. private async clearTable(tableName: string) {
  858. await this.defaultDataSource.query(`TRUNCATE TABLE "public"."${tableName}" RESTART IDENTITY RESTRICT;`);
  859. await this.defaultDataSource.query(`SELECT setval('"${tableName}_id_seq"', (SELECT max(id) FROM "${tableName}"));`);
  860. }
  861. }