fix: 加固批量出库导入流程
This commit is contained in:
@@ -137,17 +137,29 @@ export class SettingsService {
|
||||
}
|
||||
|
||||
async update(values: Record<string, string>): Promise<Record<string, string>> {
|
||||
await this.updateAtomic(values);
|
||||
return this.getAll();
|
||||
}
|
||||
|
||||
async updateAtomic(values: Record<string, string>): Promise<void> {
|
||||
const updates: Array<{ key: string; value: string }> = [];
|
||||
for (const [key, value] of Object.entries(values)) {
|
||||
if (!EDITABLE_KEYS.includes(key)) continue;
|
||||
if (MASKED_KEYS.has(key) && this.isMaskedSecret(value)) continue;
|
||||
const nextValue = SECRET_KEYS.has(key) ? await this.encryptSecret(String(value)) : String(value);
|
||||
await this.prisma.systemSetting.upsert({
|
||||
where: { key },
|
||||
update: { value: nextValue },
|
||||
create: { key, value: nextValue },
|
||||
updates.push({ key, value: nextValue });
|
||||
}
|
||||
if (updates.length) {
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
for (const { key, value } of updates) {
|
||||
await tx.systemSetting.upsert({
|
||||
where: { key },
|
||||
update: { value },
|
||||
create: { key, value },
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return this.getAll();
|
||||
}
|
||||
|
||||
// 服务内部直写(不做白名单/加密处理),用于系统自身生成的运行时值(如天河链钱包身份)
|
||||
|
||||
Reference in New Issue
Block a user