Skip to content

Commit

Permalink
修复系统设置数据未初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
whyour committed Jun 12, 2024
1 parent 372afb9 commit 46e71d8
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 34 deletions.
43 changes: 19 additions & 24 deletions back/loaders/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,23 @@ import linkDeps from './deps';
import initTask from './initTask';

export default async ({ expressApp }: { expressApp: Application }) => {
try {
depInjectorLoader();
Logger.info('✌️ Dependency Injector loaded');
console.log('✌️ Dependency Injector loaded');

expressLoader({ app: expressApp });
Logger.info('✌️ Express loaded');
console.log('✌️ Express loaded');

await initData();
Logger.info('✌️ init data loaded');
console.log('✌️ init data loaded');

await linkDeps();
Logger.info('✌️ link deps loaded');
console.log('✌️ link deps loaded');

initTask();
Logger.info('✌️ init task loaded');
console.log('✌️ init task loaded');
} catch (error) {
Logger.error(`✌️ depInjectorLoader expressLoader initData linkDeps failed, ${error}`);
console.error(`✌️ depInjectorLoader expressLoader initData linkDeps failed ${error}`);
}
depInjectorLoader();
Logger.info('✌️ Dependency loaded');
console.log('✌️ Dependency loaded');

await initData();
Logger.info('✌️ Init data loaded');
console.log('✌️ Init data loaded');

await linkDeps();
Logger.info('✌️ Link deps loaded');
console.log('✌️ Link deps loaded');

initTask();
Logger.info('✌️ Init task loaded');
console.log('✌️ Init task loaded');

expressLoader({ app: expressApp });
Logger.info('✌️ Express loaded');
console.log('✌️ Express loaded');
};
7 changes: 4 additions & 3 deletions back/loaders/initData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default async () => {
const dependenceService = Container.get(DependenceService);
const systemService = Container.get(SystemService);

// 初始化增加系统配置
await SystemModel.upsert({ type: AuthDataType.systemConfig });
await SystemModel.upsert({ type: AuthDataType.notification });

const installDependencies = () => {
// 初始化时安装所有处于安装中,安装成功,安装失败的依赖
DependenceModel.findAll({
Expand Down Expand Up @@ -158,7 +162,4 @@ export default async () => {
// 初始化保存一次ck和定时任务数据
await cronService.autosave_crontab();
await envService.set_envs();

// 初始化增加系统配置
await SystemModel.upsert({ type: AuthDataType.systemConfig });
};
2 changes: 1 addition & 1 deletion back/services/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export default class CronService {
public async getDb(query: FindOptions<Crontab>['where']): Promise<Crontab> {
const doc: any = await CrontabModel.findOne({ where: { ...query } });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
throw new Error(`Cron ${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
Expand Down
2 changes: 1 addition & 1 deletion back/services/cronView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class CronViewService {
): Promise<CrontabView> {
const doc: any = await CrontabViewModel.findOne({ where: { ...query } });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
throw new Error(`CronView ${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
Expand Down
2 changes: 1 addition & 1 deletion back/services/dependence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default class DependenceService {
): Promise<Dependence> {
const doc: any = await DependenceModel.findOne({ where: { ...query } });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
throw new Error(`Dependency ${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
Expand Down
2 changes: 1 addition & 1 deletion back/services/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default class EnvService {
public async getDb(query: FindOptions<Env>['where']): Promise<Env> {
const doc: any = await EnvModel.findOne({ where: { ...query } });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
throw new Error(`Env ${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
Expand Down
2 changes: 1 addition & 1 deletion back/services/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class OpenService {
public async getDb(query: any): Promise<App> {
const doc: any = await AppModel.findOne({ where: query });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
throw new Error(`App ${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
Expand Down
2 changes: 1 addition & 1 deletion back/services/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default class SubscriptionService {
): Promise<Subscription> {
const doc = await SubscriptionModel.findOne({ where: { ...query } });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
throw new Error(`Subscription ${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
Expand Down
2 changes: 1 addition & 1 deletion back/services/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class SystemService {
public async getDb(query: any): Promise<SystemInfo> {
const doc = await SystemModel.findOne({ where: { ...query } });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
throw new Error(`System ${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
Expand Down

0 comments on commit 46e71d8

Please sign in to comment.