fix: 加固批量出库导入流程

This commit is contained in:
Nixevol
2026-07-14 07:02:41 +08:00
parent 3c74f03e7e
commit 9644f5c128
54 changed files with 5292 additions and 516 deletions
+17 -5
View File
@@ -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();
}
// 服务内部直写(不做白名单/加密处理),用于系统自身生成的运行时值(如天河链钱包身份)