|
@@ -7,6 +7,7 @@ import { DictData } from '../../entity/system/dictData.entity';
|
|
import { DictType } from '../../entity/system/dictType.entity';
|
|
import { DictType } from '../../entity/system/dictType.entity';
|
|
import { Menus } from '../../entity/system/menus.entity';
|
|
import { Menus } from '../../entity/system/menus.entity';
|
|
import { Role } from '../../entity/system/role.entity';
|
|
import { Role } from '../../entity/system/role.entity';
|
|
|
|
+import { Config } from '../../entity/system/config.entity';
|
|
const ObjectId = Types.ObjectId;
|
|
const ObjectId = Types.ObjectId;
|
|
@Autoload()
|
|
@Autoload()
|
|
@Scope(ScopeEnum.Singleton)
|
|
@Scope(ScopeEnum.Singleton)
|
|
@@ -21,6 +22,8 @@ export class InitService {
|
|
dictTypeModel: ReturnModelType<typeof DictType>;
|
|
dictTypeModel: ReturnModelType<typeof DictType>;
|
|
@InjectEntityModel(DictData)
|
|
@InjectEntityModel(DictData)
|
|
dictDataModel: ReturnModelType<typeof DictData>;
|
|
dictDataModel: ReturnModelType<typeof DictData>;
|
|
|
|
+ @InjectEntityModel(Config)
|
|
|
|
+ configModel: ReturnModelType<typeof Config>;
|
|
@Init()
|
|
@Init()
|
|
async init() {
|
|
async init() {
|
|
console.log('to init');
|
|
console.log('to init');
|
|
@@ -28,7 +31,15 @@ export class InitService {
|
|
this.initRole();
|
|
this.initRole();
|
|
this.initMenus();
|
|
this.initMenus();
|
|
this.initDict();
|
|
this.initDict();
|
|
|
|
+ this.initConfig();
|
|
}
|
|
}
|
|
|
|
+ async initConfig() {
|
|
|
|
+ const data = { logo: [], name: '平台名', fields: [] };
|
|
|
|
+ const num = await this.configModel.count();
|
|
|
|
+ if (num > 0) return;
|
|
|
|
+ await this.configModel.create(data);
|
|
|
|
+ }
|
|
|
|
+
|
|
async adminUser() {
|
|
async adminUser() {
|
|
const data = {
|
|
const data = {
|
|
account: 'admin',
|
|
account: 'admin',
|
|
@@ -72,6 +83,16 @@ export class InitService {
|
|
route_name: 'system',
|
|
route_name: 'system',
|
|
is_default: '0',
|
|
is_default: '0',
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ name: '平台设置',
|
|
|
|
+ parent_id: smId.toString(),
|
|
|
|
+ order_num: 1,
|
|
|
|
+ path: '/system/config',
|
|
|
|
+ component: '/system/config/index',
|
|
|
|
+ type: '1',
|
|
|
|
+ route_name: 'system_config',
|
|
|
|
+ is_default: '0',
|
|
|
|
+ },
|
|
{
|
|
{
|
|
name: '目录设置',
|
|
name: '目录设置',
|
|
parent_id: smId.toString(),
|
|
parent_id: smId.toString(),
|
|
@@ -202,6 +223,8 @@ export class InitService {
|
|
async initRoleMenu(admin: Admin) {}
|
|
async initRoleMenu(admin: Admin) {}
|
|
|
|
|
|
async initDict() {
|
|
async initDict() {
|
|
|
|
+ const num = await this.dictTypeModel.count();
|
|
|
|
+ if (num > 0) return;
|
|
const isUseType = [{ title: '是否使用', code: 'isUse', is_use: '0' }];
|
|
const isUseType = [{ title: '是否使用', code: 'isUse', is_use: '0' }];
|
|
const isUseData = [
|
|
const isUseData = [
|
|
{ code: 'isUse', label: '使用', value: '0', sort: 1, is_use: '0' },
|
|
{ code: 'isUse', label: '使用', value: '0', sort: 1, is_use: '0' },
|