Dev Main by v3.4 测试数据删除 #10

Merged
jacy merged 91 commits from dev into main 2026-07-28 17:19:22 +08:00
Showing only changes of commit 78973e3fbf - Show all commits
@@ -184,16 +184,22 @@ export class SystemConfigService implements OnModuleInit {
async importFromProcessEnv(): Promise<{ imported: number }> { async importFromProcessEnv(): Promise<{ imported: number }> {
let imported = 0; let imported = 0;
const overlay: Record<string, string> = {};
for (const field of SYSTEM_CONFIG_FIELDS) { for (const field of SYSTEM_CONFIG_FIELDS) {
const envVal = process.env[field.key]; const envVal = process.env[field.key];
if (envVal === undefined || envVal === '') continue; if (envVal === undefined || envVal === '') continue;
const normalized = this.normalizeByMeta(field, envVal);
const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } }); const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
if (existing) continue; if (existing?.value?.trim()) continue;
await this.prisma.systemConfig.create({ await this.prisma.systemConfig.upsert({
data: { configKey: field.key, value: this.normalizeByMeta(field, envVal) }, where: { configKey: field.key },
create: { configKey: field.key, value: normalized },
update: { value: normalized },
}); });
overlay[field.key] = normalized;
imported += 1; imported += 1;
} }
if (imported) applyEnvOverlay(overlay);
await this.onModuleInit(); await this.onModuleInit();
return { imported }; return { imported };
} }
@@ -208,12 +214,15 @@ export class SystemConfigService implements OnModuleInit {
private async seedMissingFromProcessEnv() { private async seedMissingFromProcessEnv() {
for (const field of SYSTEM_CONFIG_FIELDS) { for (const field of SYSTEM_CONFIG_FIELDS) {
const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
if (existing) continue;
const envVal = process.env[field.key]; const envVal = process.env[field.key];
if (envVal === undefined || envVal === '') continue; if (envVal === undefined || envVal === '') continue;
await this.prisma.systemConfig.create({ const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
data: { configKey: field.key, value: this.normalizeByMeta(field, envVal) }, if (existing?.value?.trim()) continue;
const value = this.normalizeByMeta(field, envVal);
await this.prisma.systemConfig.upsert({
where: { configKey: field.key },
create: { configKey: field.key, value },
update: { value },
}); });
} }
} }