|
@@ -1,8 +1,8 @@
|
|
|
import { Provide } from '@midwayjs/core';
|
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
|
-import { Repository } from 'typeorm';
|
|
|
+import { In, Repository } from 'typeorm';
|
|
|
import { Menus } from '../../entity/system/menus.entity';
|
|
|
-import { get, isNull, isUndefined } from 'lodash';
|
|
|
+import { get, isNull, isUndefined, omit } from 'lodash';
|
|
|
import { User } from '../../entity/system/user.entity';
|
|
|
import { Admin } from '../../entity/system/admin.entity';
|
|
|
import { Achievement } from '../../entity/platform/achievement.entity';
|
|
@@ -17,6 +17,8 @@ import { Project } from '../../entity/platform/project.entity';
|
|
|
import { Sector } from '../../entity/platform/sector.entity';
|
|
|
import { Supply } from '../../entity/platform/supply.entity';
|
|
|
import { Support } from '../../entity/platform/support.entity';
|
|
|
+import { UserMenus } from '../../entity/system/userMenus.entity';
|
|
|
+import { Role } from '../../entity/system/role.entity';
|
|
|
|
|
|
@Provide()
|
|
|
export class DataDealService {
|
|
@@ -51,6 +53,209 @@ export class DataDealService {
|
|
|
@InjectEntityModel(Support)
|
|
|
Support: Repository<Support>;
|
|
|
|
|
|
+ @InjectEntityModel(UserMenus)
|
|
|
+ UserMenus: Repository<UserMenus>;
|
|
|
+
|
|
|
+ @InjectEntityModel(Role)
|
|
|
+ Role: Repository<Role>;
|
|
|
+
|
|
|
+ /**初始化用户目录,先去数据库把表清空,顺便重置下id索引 */
|
|
|
+ async initUserMenus() {
|
|
|
+ console.log(' in initUserMenus ');
|
|
|
+ await this.UserMenus.query('TRUNCATE TABLE "public"."userMenus" RESTART IDENTITY RESTRICT;');
|
|
|
+ const datas = [
|
|
|
+ {
|
|
|
+ order_num: 0,
|
|
|
+ name: '基础信息',
|
|
|
+ route_name: 'center_base',
|
|
|
+ i18n_code: 'menus.center_base',
|
|
|
+ path: '/center/base',
|
|
|
+ component: '/center/base/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 1,
|
|
|
+ name: '认证信息',
|
|
|
+ route_name: 'center_role',
|
|
|
+ i18n_code: 'menus.center_role',
|
|
|
+ path: '/center/role',
|
|
|
+ component: '/center/role/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 2,
|
|
|
+ name: '消息通知',
|
|
|
+ route_name: 'center_notice',
|
|
|
+ i18n_code: 'menus.center_notice',
|
|
|
+ path: '/center/notice',
|
|
|
+ component: '/center/notice/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 3,
|
|
|
+ name: '行业动态',
|
|
|
+ route_name: 'center_news2',
|
|
|
+ i18n_code: 'menus.center_news2',
|
|
|
+ path: '/center/news2',
|
|
|
+ component: '/center/news2/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 4,
|
|
|
+ name: '需求管理',
|
|
|
+ route_name: 'center_demand',
|
|
|
+ i18n_code: 'menus.center_demand',
|
|
|
+ path: '/center/demand',
|
|
|
+ component: '/center/demand/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 5,
|
|
|
+ name: '供给管理',
|
|
|
+ route_name: 'center_supply',
|
|
|
+ i18n_code: 'menus.center_supply',
|
|
|
+ path: '/center/supply',
|
|
|
+ component: '/center/supply/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 6,
|
|
|
+ name: '成果管理',
|
|
|
+ route_name: 'center_achievement',
|
|
|
+ i18n_code: 'menus.center_achievement',
|
|
|
+ path: '/center/achievement',
|
|
|
+ component: '/center/achievement/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 7,
|
|
|
+ name: '项目管理',
|
|
|
+ route_name: 'center_project',
|
|
|
+ i18n_code: 'menus.center_project',
|
|
|
+ path: '/center/project',
|
|
|
+ component: '/center/project/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 8,
|
|
|
+ name: '中试管理',
|
|
|
+ route_name: 'center_footplate',
|
|
|
+ i18n_code: 'menus.center_footplate',
|
|
|
+ path: '/center/footplate',
|
|
|
+ component: '/center/footplate/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 9,
|
|
|
+ name: '赛事管理',
|
|
|
+ route_name: 'center_match',
|
|
|
+ i18n_code: 'menus.center_match',
|
|
|
+ path: '/center/match',
|
|
|
+ component: '/center/match/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 10,
|
|
|
+ name: '报名管理',
|
|
|
+ route_name: 'center_sign',
|
|
|
+ i18n_code: 'menus.center_sign',
|
|
|
+ path: '/center/sign',
|
|
|
+ component: '/center/sign/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 11,
|
|
|
+ name: '产研行研',
|
|
|
+ route_name: 'center_journal',
|
|
|
+ i18n_code: 'menus.center_journal',
|
|
|
+ path: '/center/journal',
|
|
|
+ component: '/center/journal/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 998,
|
|
|
+ name: '收藏管理',
|
|
|
+ route_name: 'center_collection',
|
|
|
+ i18n_code: 'menus.center_collection',
|
|
|
+ path: '/center/collection',
|
|
|
+ component: '/center/collection/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ order_num: 999,
|
|
|
+ name: '修改密码',
|
|
|
+ route_name: 'center_password',
|
|
|
+ i18n_code: 'menus.center_password',
|
|
|
+ path: '/center/password',
|
|
|
+ component: '/center/password/index',
|
|
|
+ type: '1',
|
|
|
+ config: [],
|
|
|
+ is_default: '0',
|
|
|
+ is_use: '0',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ await this.UserMenus.insert(datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ async initRoleMenus() {
|
|
|
+ /**
|
|
|
+ * 初始化角色的菜单
|
|
|
+ * 共有: 基础信息,认证信息,行业动态,
|
|
|
+ */
|
|
|
+ const common = ['center_base', 'center_role', 'center_notice', 'center_collection', 'center_password', 'center_sign'];
|
|
|
+ // 只用通用菜单的角色
|
|
|
+ const justCommonRole = ['User', 'Association', 'Investment', 'State'];
|
|
|
+ await this.Role.update({ code: In(justCommonRole) }, { menu: common });
|
|
|
+ // 第一类菜单
|
|
|
+ const menus1 = [...common, 'center_news2', 'center_demand', 'center_supply', 'center_achievement', 'center_project', 'center_footplate'];
|
|
|
+ // 第一类菜单用户: 用户,科研机构,孵化器,企业,高校
|
|
|
+ const roleUseMenus1 = ['Expert', 'Unit', 'Incubator', 'Company', 'GX'];
|
|
|
+ await this.Role.update({ code: In(roleUseMenus1) }, { menu: menus1 });
|
|
|
+ // 创业大赛用户: 需要去掉报名管理,加入赛事管理
|
|
|
+ const MatchRole = common.filter(f => f != 'center_sign');
|
|
|
+ MatchRole.push('center_match');
|
|
|
+ await this.Role.update({ code: In(['Competition']) }, { menu: MatchRole });
|
|
|
+ }
|
|
|
+
|
|
|
count = 0;
|
|
|
|
|
|
isNoValue(val) {
|