mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复初始化 SystemConfig 数据
This commit is contained in:
parent
43d6ac2071
commit
cecc5aeb15
|
@ -26,9 +26,15 @@ export default async () => {
|
||||||
const openService = Container.get(OpenService);
|
const openService = Container.get(OpenService);
|
||||||
|
|
||||||
// 初始化增加系统配置
|
// 初始化增加系统配置
|
||||||
await SystemModel.upsert({ type: AuthDataType.systemConfig });
|
await SystemModel.findOrCreate({
|
||||||
await SystemModel.upsert({ type: AuthDataType.notification });
|
where: { type: AuthDataType.systemConfig },
|
||||||
await SystemModel.upsert({ type: AuthDataType.authConfig });
|
});
|
||||||
|
await SystemModel.findOrCreate({
|
||||||
|
where: { type: AuthDataType.notification },
|
||||||
|
});
|
||||||
|
await SystemModel.findOrCreate({
|
||||||
|
where: { type: AuthDataType.authConfig },
|
||||||
|
});
|
||||||
const authConfig = await SystemModel.findOne({
|
const authConfig = await SystemModel.findOne({
|
||||||
where: { type: AuthDataType.authConfig },
|
where: { type: AuthDataType.authConfig },
|
||||||
});
|
});
|
||||||
|
|
|
@ -54,13 +54,14 @@ export default class SystemService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateAuthDb(payload: SystemInfo): Promise<SystemInfo> {
|
private async updateAuthDb(payload: SystemInfo): Promise<SystemInfo> {
|
||||||
await SystemModel.upsert({ ...payload });
|
const { id, ...others } = payload;
|
||||||
const doc = await this.getDb({ type: payload.type });
|
await SystemModel.update(others, { where: { id } });
|
||||||
|
const doc = await this.getDb({ id });
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getDb(query: any): Promise<SystemInfo> {
|
public async getDb(query: any): Promise<SystemInfo> {
|
||||||
const doc = await SystemModel.findOne({ where: { ...query } });
|
const doc = await SystemModel.findOne({ where: query });
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
throw new Error(`System ${JSON.stringify(query)} not found`);
|
throw new Error(`System ${JSON.stringify(query)} not found`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,7 +334,7 @@ export default class UserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateAuthDb(payload: SystemInfo): Promise<any> {
|
private async updateAuthDb(payload: SystemInfo): Promise<any> {
|
||||||
let doc = await SystemModel.findOne({ type: payload.type });
|
let doc = await SystemModel.findOne({ where: { type: payload.type } });
|
||||||
if (doc) {
|
if (doc) {
|
||||||
const updateResult = await SystemModel.update(payload, {
|
const updateResult = await SystemModel.update(payload, {
|
||||||
where: { id: doc.id },
|
where: { id: doc.id },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user