feat(admin): 增加审计与一致性页面

This commit is contained in:
2026-07-08 17:05:16 +08:00
parent ea0b631a83
commit 988d659fcc
9 changed files with 482 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
import { api } from './api';
export type ConsistencySeverity = 'ok' | 'warn' | 'error';
export type ConsistencyStatus = 'pass' | 'fail';
export interface ConsistencyCheckResult {
id: string;
label: string;
severity: ConsistencySeverity;
count: number;
message: string;
}
export interface ConsistencyResult {
generatedAt: string;
status: ConsistencyStatus;
counts: Record<string, number>;
checks: {
partitionKeys: ConsistencyCheckResult[];
orphanReferences: ConsistencyCheckResult[];
auditCoverage: ConsistencyCheckResult[];
};
summary: {
errors: number;
warnings: number;
human: string;
};
}
export function getConsistencyReport() {
return api.get<ConsistencyResult>('/consistency');
}
export function summarizeConsistencyResult(result: ConsistencyResult) {
const checks = [
...result.checks.partitionKeys,
...result.checks.orphanReferences,
...result.checks.auditCoverage,
];
return {
ok: checks.filter((item) => item.severity === 'ok').length,
warn: checks.filter((item) => item.severity === 'warn').length,
error: checks.filter((item) => item.severity === 'error').length,
total: checks.length,
};
}