feat: 实现出库导入、区块链存证、查询日志、看板与系统设置

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 16:25:03 +08:00
co-authored by Cursor
parent 63c0488ff7
commit 23cbf37aa1
20 changed files with 720 additions and 6 deletions
+41
View File
@@ -0,0 +1,41 @@
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { PrismaService } from '../prisma/prisma.service';
const EDITABLE_KEYS = ['appName', 'logRetentionDays', 'watermarkText'];
@Injectable()
export class SettingsService {
constructor(
private readonly prisma: PrismaService,
private readonly config: ConfigService,
) {}
async getAll(): Promise<Record<string, string>> {
const rows = await this.prisma.systemSetting.findMany();
const map: Record<string, string> = {
appName: this.config.get<string>('appName') || '',
logRetentionDays: String(this.config.get<number>('logRetentionDays') || 365),
watermarkText: this.config.get<string>('watermarkText') || '仅供溯源核验使用',
};
for (const r of rows) map[r.key] = r.value;
return map;
}
async get(key: string): Promise<string | null> {
const row = await this.prisma.systemSetting.findUnique({ where: { key } });
return row?.value ?? null;
}
async update(values: Record<string, string>): Promise<Record<string, string>> {
for (const [key, value] of Object.entries(values)) {
if (!EDITABLE_KEYS.includes(key)) continue;
await this.prisma.systemSetting.upsert({
where: { key },
update: { value: String(value) },
create: { key, value: String(value) },
});
}
return this.getAll();
}
}