feat(shipping-notice): 增强发货通知与审计功能,支持敏感数据控制与哈希链校验

- 更新发货通知工具 API,剥离不可信的操作人身份字段,确保审计安全
- 引入审计事件的哈希链校验机制,支持数据完整性验证
- 增强订单抽取与审计功能,支持敏感快照的访问控制
- 更新相关模型与服务,确保新功能的完整性与可追溯性
- 完善文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
hugo committed 2026-07-31 08:59:44 +08:00
1 parent 95cdfe66b0
commit d0fe084999
225 files changed
+25923 -6653

No files matched your search

@@ -1,8 +1,9 @@
/**
* features/admin/api/shipping-audit.api.ts
* 用途:货代统一审计查询/详情/导出 HTTP 客户端。
* 用途:货代统一审计查询/详情/关联链/哈希校验/导出 HTTP 客户端。
* 依赖:shared/api/client、getAuthHeaders。
* 逻辑:由 ShippingAuditCenterPage 调用;导出走 blob 下载并保留服务端文件名。
* 逻辑:由 ShippingAuditCenterPage / ShippingAuditEventDetailDrawer 调用;
* 导出走 blob 下载;敏感详情由后端按 audit_sensitive_read 裁剪。
*/
import { requestJson } from '@/shared/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
@@ -16,7 +17,8 @@ export type ShippingAuditEventSummary = {
task_no?: string | null;
document_id?: string | null;
conversation_id?: string | null;
session_item_id?: string | null;
workflow_id?: string | null;
workflow_item_id?: string | null;
review_case_no?: string | null;
owner_user_id?: string | null;
actor_type: string;
@@ -27,7 +29,11 @@ export type ShippingAuditEventSummary = {
action?: string | null;
reason_code?: string | null;
error_code?: string | null;
sensitivity_level?: string | null;
previous_event_hash?: string | null;
event_hash?: string | null;
has_snapshots: boolean;
sensitive_redacted?: boolean;
created_at?: string | null;
};
@@ -42,6 +48,7 @@ export type ShippingAuditEventDetail = ShippingAuditEventSummary & {
before_snapshot?: Record<string, unknown> | null;
after_snapshot?: Record<string, unknown> | null;
diff?: ShippingAuditDiffRow[];
diff_json?: Record<string, unknown> | null;
metadata?: Record<string, unknown>;
evidence_refs?: Array<Record<string, unknown>>;
artifact_refs?: Array<Record<string, unknown>>;
@@ -57,13 +64,10 @@ export type ShippingAuditFilters = {
document_id?: string;
operation_id?: string;
request_id?: string;
/** 会话 ID;与后端 conversation_id 筛选对齐 */
conversation_id?: string;
/** 会话 PDF 工作项编号 */
session_item_id?: string;
/** 人工复核 Case 编号 */
workflow_id?: string;
workflow_item_id?: string;
review_case_no?: string;
/** 工作项属主用户 ID */
owner_user_id?: string;
result?: string;
created_from?: string;
@@ -71,6 +75,23 @@ export type ShippingAuditFilters = {
q?: string;
};
export type ShippingAuditAssociationChain = {
items: ShippingAuditEventSummary[];
total: number;
association_keys: Record<string, string[]>;
truncated: boolean;
limit: number;
};
export type ShippingAuditHashVerifyResult = {
ok: boolean;
checked_chains: number;
failed_chains: number;
failures_sample: Array<Record<string, unknown>>;
mode?: string;
skipped?: boolean;
};
const auth = () => ({ headers: getAuthHeaders() });
/**
@@ -88,7 +109,7 @@ export function listShippingAuditEvents(page = 1, pageSize = 25, filters: Shippi
}
/**
* 读取单条审计详情(含白名单快照与 diff)。
* 读取单条审计详情(含白名单快照与 diff;敏感项可能脱敏)。
*/
export function getShippingAuditEvent(eventId: number) {
return requestJson<ShippingAuditEventDetail>(
@@ -97,6 +118,40 @@ export function getShippingAuditEvent(eventId: number) {
);
}
/**
* 按 Workflow / Item / Run / PDF / Case / Task 关联键追溯全链。
*/
export function listShippingAuditAssociationChain(filters: ShippingAuditFilters = {}, limit = 500) {
const params = new URLSearchParams({ limit: String(limit) });
Object.entries(filters).forEach(([key, value]) => {
if (value) params.set(key, String(value));
});
return requestJson<ShippingAuditAssociationChain>(
`/api/admin/shipping-notice/audit-events/association-chain?${params}`,
auth(),
);
}
/**
* 校验审计哈希链完整性。
*/
export function verifyShippingAuditHashChain(body: {
aggregate_type?: string;
aggregate_id?: string;
workflow_id?: string;
workflow_item_id?: string;
sample_limit?: number;
} = {}) {
return requestJson<ShippingAuditHashVerifyResult>(
'/api/admin/shipping-notice/audit-events/verify-hash-chain',
{
method: 'POST',
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
body: JSON.stringify(body),
},
);
}
/**
* 受控导出审计 CSV/JSON,并触发浏览器下载。
*/