mirror of
https://github.com/certd/certd.git
synced 2026-05-16 04:58:57 +08:00
feat: 升级midway,支持esm
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { Autoload, Init, Inject, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { logger } from '../../utils/logger.js';
|
||||
import { UserService } from '../authority/service/user-service.js';
|
||||
import { SysSettingsService } from '../system/service/sys-settings-service.js';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { SysInstallInfo } from '../system/service/models.js';
|
||||
|
||||
export type InstallInfo = {
|
||||
installTime: number;
|
||||
instanceId?: string;
|
||||
};
|
||||
|
||||
@Autoload()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class AutoInitSite {
|
||||
@Inject()
|
||||
userService: UserService;
|
||||
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
|
||||
@Init()
|
||||
async init() {
|
||||
logger.info('初始化站点开始');
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
if (!installInfo.siteId) {
|
||||
installInfo.siteId = nanoid();
|
||||
await this.sysSettingsService.saveSetting(installInfo);
|
||||
}
|
||||
if (!installInfo.siteId) {
|
||||
installInfo.siteId = nanoid();
|
||||
await this.sysSettingsService.saveSetting(installInfo);
|
||||
}
|
||||
|
||||
logger.info('初始化站点完成');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user