feat(message): add cross-module event integration (Phase 6)
- Message module subscribes to workflow events (process_instance.started) - Auto-generates notifications when workflows start - Added started_by to workflow instance event payload - Event listener runs as background tokio task Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,7 @@ impl InstanceService {
|
||||
let mut variables = HashMap::new();
|
||||
if let Some(vars) = &req.variables {
|
||||
for v in vars {
|
||||
let var_type = v.var_type.as_deref().unwrap_or("string");
|
||||
let _var_type = v.var_type.as_deref().unwrap_or("string");
|
||||
variables.insert(v.name.clone(), v.value.clone());
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,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 }),
|
||||
serde_json::json!({ "instance_id": instance_id, "definition_id": definition.id, "started_by": operator_id }),
|
||||
));
|
||||
|
||||
// 查询创建后的实例(包含 token)
|
||||
@@ -169,7 +169,7 @@ impl InstanceService {
|
||||
.await
|
||||
.map_err(|e| WorkflowError::Validation(e.to_string()))?;
|
||||
|
||||
let page_index = pagination.page.unwrap_or(1).saturating_sub(1) as u64;
|
||||
let page_index = pagination.page.unwrap_or(1).saturating_sub(1);
|
||||
let models = paginator
|
||||
.fetch_page(page_index)
|
||||
.await
|
||||
@@ -325,7 +325,7 @@ impl InstanceService {
|
||||
) -> WorkflowResult<()> {
|
||||
let id = Uuid::now_v7();
|
||||
|
||||
let (value_string, value_number, value_boolean, value_date): (Option<String>, Option<f64>, Option<bool>, Option<chrono::DateTime<Utc>>) = match var_type {
|
||||
let (value_string, value_number, value_boolean, _value_date): (Option<String>, Option<f64>, Option<bool>, Option<chrono::DateTime<Utc>>) = match var_type {
|
||||
"string" => (value.as_str().map(|s| s.to_string()), None, None, None),
|
||||
"number" => (None, value.as_f64(), None, None),
|
||||
"boolean" => (None, None, value.as_bool(), None),
|
||||
|
||||
Reference in New Issue
Block a user