feat(core): build_event_payload 统一信封 — 28 处事件发布全部迁移

- erp-core 添加 build_event_payload(),自动注入 schema_version + occurred_at
- erp-health 12 个 service(25 处)、erp-auth(1 处)、erp-workflow(2 处)
  全部迁移到统一信封格式
This commit is contained in:
iven
2026-04-27 18:01:05 +08:00
parent d31d7beb1f
commit 97bb592688
16 changed files with 63 additions and 41 deletions

View File

@@ -115,11 +115,11 @@ impl WorkflowModule {
let event = erp_core::events::DomainEvent::new(
"task.timeout",
*tenant_id,
serde_json::json!({
erp_core::events::build_event_payload(serde_json::json!({
"task_id": task_id,
"instance_id": instance_id,
"assignee_id": assignee_id,
}),
})),
);
event_bus.publish(event, &db).await;
}

View File

@@ -126,7 +126,7 @@ impl InstanceService {
event_bus.publish(erp_core::events::DomainEvent::new(
"process_instance.started",
tenant_id,
serde_json::json!({ "instance_id": instance_id, "definition_id": definition.id, "started_by": operator_id }),
erp_core::events::build_event_payload(serde_json::json!({ "instance_id": instance_id, "definition_id": definition.id, "started_by": operator_id })),
), db).await;
audit_service::record(
@@ -323,7 +323,7 @@ impl InstanceService {
tenant_id: Set(tenant_id),
event_type: Set(event_type),
payload: Set(Some(
serde_json::json!({ "instance_id": id, "changed_by": operator_id }),
erp_core::events::build_event_payload(serde_json::json!({ "instance_id": id, "changed_by": operator_id })),
)),
correlation_id: Set(Some(Uuid::now_v7())),
status: Set("pending".to_string()),