|
@@ -10,7 +10,7 @@ import { Menus } from '../../entity/system/menus.entity';
|
|
|
import { Role } from '../../entity/system/role.entity';
|
|
|
import { Admin } from '../../entity/system/admin.entity';
|
|
|
// import * as fs from 'fs'
|
|
|
-import InitMenusData from '../../initData/menus'
|
|
|
+import InitMenusData from '../../initData/menus';
|
|
|
@Autoload()
|
|
|
@Scope(ScopeEnum.Singleton)
|
|
|
export class InitService {
|
|
@@ -27,7 +27,6 @@ export class InitService {
|
|
|
@InjectEntityModel(Config)
|
|
|
configModel: Repository<Config>;
|
|
|
|
|
|
-
|
|
|
@Init()
|
|
|
async init() {
|
|
|
this.adminUser();
|
|
@@ -35,20 +34,19 @@ export class InitService {
|
|
|
this.initMenus();
|
|
|
this.initDict();
|
|
|
this.initConfig();
|
|
|
- this.initSelfMenus()
|
|
|
+ this.initSelfMenus();
|
|
|
}
|
|
|
|
|
|
async initSelfMenus() {
|
|
|
for (const i of InitMenusData) {
|
|
|
- const route_name = get(i, 'route_name')
|
|
|
+ const route_name = get(i, 'route_name');
|
|
|
if (!route_name) continue;
|
|
|
- const num = await this.menusModel.count({ where: { route_name } })
|
|
|
+ const num = await this.menusModel.count({ where: { route_name } });
|
|
|
if (num > 0) continue;
|
|
|
await this.menusModel.insert(i);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
async initConfig() {
|
|
|
const data: any = { logo: [], name: '平台名', index_img: [] };
|
|
|
const num = await this.configModel.count();
|
|
@@ -66,7 +64,7 @@ export class InitService {
|
|
|
is_super: '0',
|
|
|
};
|
|
|
|
|
|
- const query: any = { is_super: '0' }
|
|
|
+ const query: any = { is_super: '0' };
|
|
|
const is_exist = await this.adminModel.count({ where: query });
|
|
|
if (!is_exist) return await this.adminModel.insert(data);
|
|
|
return;
|
|
@@ -102,7 +100,7 @@ export class InitService {
|
|
|
is_default: '0',
|
|
|
};
|
|
|
const rsd = await this.menusModel.insert(sd);
|
|
|
- const smId = get(rsd, 'identifiers.0.id')
|
|
|
+ const smId = get(rsd, 'identifiers.0.id');
|
|
|
const systemMenus = [
|
|
|
{
|
|
|
name: '平台设置',
|
|
@@ -194,6 +192,16 @@ export class InitService {
|
|
|
route_name: 'system_dict_data',
|
|
|
is_default: '0',
|
|
|
},
|
|
|
+ {
|
|
|
+ name: '满意度调查设置',
|
|
|
+ parent_id: smId,
|
|
|
+ order_num: 5,
|
|
|
+ path: '/system/setting',
|
|
|
+ component: '/system/setting/index',
|
|
|
+ type: '1',
|
|
|
+ route_name: 'system_setting',
|
|
|
+ is_default: '0',
|
|
|
+ },
|
|
|
];
|
|
|
await this.menusModel.insert(systemMenus);
|
|
|
|
|
@@ -207,7 +215,7 @@ export class InitService {
|
|
|
is_default: '1',
|
|
|
};
|
|
|
const rud = await this.menusModel.insert(ud);
|
|
|
- const umId = get(rud, 'identifiers.0.id')
|
|
|
+ const umId = get(rud, 'identifiers.0.id');
|
|
|
const userMenus = [
|
|
|
{
|
|
|
name: '管理员用户',
|
|
@@ -230,6 +238,26 @@ export class InitService {
|
|
|
];
|
|
|
await this.menusModel.insert(userMenus);
|
|
|
|
|
|
+ const question = {
|
|
|
+ name: '投诉与建议',
|
|
|
+ order_num: 4,
|
|
|
+ path: '/question',
|
|
|
+ component: '/question/index',
|
|
|
+ type: '1',
|
|
|
+ route_name: 'question',
|
|
|
+ };
|
|
|
+ await this.menusModel.insert(question);
|
|
|
+
|
|
|
+ const result = {
|
|
|
+ name: '满意度调查结果',
|
|
|
+ order_num: 5,
|
|
|
+ path: '/result',
|
|
|
+ component: '/result/index',
|
|
|
+ type: '1',
|
|
|
+ route_name: 'result',
|
|
|
+ };
|
|
|
+ await this.menusModel.insert(result);
|
|
|
+
|
|
|
const password = {
|
|
|
name: '账号管理',
|
|
|
order_num: 999,
|
|
@@ -240,7 +268,7 @@ export class InitService {
|
|
|
};
|
|
|
await this.menusModel.insert(password);
|
|
|
}
|
|
|
- async initRoleMenu(admin: Admin) { }
|
|
|
+ async initRoleMenu(admin: Admin) {}
|
|
|
|
|
|
async initDict() {
|
|
|
const num = await this.dictTypeModel.count();
|
|
@@ -253,5 +281,4 @@ export class InitService {
|
|
|
await this.dictTypeModel.insert(isUseType);
|
|
|
await this.dictDataModel.insert(isUseData);
|
|
|
}
|
|
|
-
|
|
|
}
|