系统设置增加依赖代理和镜像源设置

This commit is contained in:
whyour
2023-11-06 23:55:16 +08:00
parent 4a3ac7dc4b
commit 9ed107980c
10 changed files with 213 additions and 38 deletions
+10 -11
View File
@@ -5,10 +5,10 @@ import config from '../config';
import {
AuthDataType,
AuthInfo,
AuthInstance,
AuthModel,
AuthModelInfo,
} from '../data/auth';
SystemInstance,
SystemModel,
SystemModelInfo,
} from '../data/system';
import { NotificationInfo } from '../data/notify';
import NotificationService from './notify';
import ScheduleService, { TaskCallbacks } from './schedule';
@@ -43,17 +43,17 @@ export default class SystemService {
public async getSystemConfig() {
const doc = await this.getDb({ type: AuthDataType.systemConfig });
return doc || ({} as AuthInstance);
return doc || ({} as SystemInstance);
}
private async updateAuthDb(payload: AuthInfo): Promise<AuthInstance> {
await AuthModel.upsert({ ...payload });
private async updateAuthDb(payload: AuthInfo): Promise<SystemInstance> {
await SystemModel.upsert({ ...payload });
const doc = await this.getDb({ type: payload.type });
return doc;
}
public async getDb(query: any): Promise<AuthInstance> {
const doc: any = await AuthModel.findOne({ where: { ...query } });
public async getDb(query: any): Promise<SystemInstance> {
const doc: any = await SystemModel.findOne({ where: { ...query } });
return doc && doc.get({ plain: true });
}
@@ -75,11 +75,10 @@ export default class SystemService {
}
}
public async updateSystemConfig(info: AuthModelInfo) {
public async updateSystemConfig(info: SystemModelInfo) {
const oDoc = await this.getSystemConfig();
const result = await this.updateAuthDb({
...oDoc,
type: AuthDataType.systemConfig,
info,
});
if (info.logRemoveFrequency) {