fix(core): 消除乐观锁 version.unwrap() 潜在 panic
20 处 ActiveValue::unwrap() + 1 乐观锁递增改为 take().unwrap_or(0) + 1, 避免数据库记录缺少 version 字段时 panic。覆盖 erp-auth/erp-config/ erp-workflow/erp-health/erp-ai/erp-server 7 个 crate。 DTO 层 Option<i32> 字段保持原有 unwrap_or(0) 不变。
This commit is contained in:
@@ -108,7 +108,7 @@ async fn handle_dialysis_record_created(
|
||||
.ok_or("透析记录不存在")?;
|
||||
|
||||
let mut active: erp_dialysis::entity::dialysis_record::ActiveModel = record.into();
|
||||
active.version = Set(active.version.unwrap() + 1);
|
||||
active.version = Set(active.version.take().unwrap_or(0) + 1);
|
||||
active.workflow_instance_id = Set(Some(result.id));
|
||||
active.updated_at = Set(chrono::Utc::now());
|
||||
active.update(db).await?;
|
||||
|
||||
Reference in New Issue
Block a user