fix: P0 止血 — 消除崩溃风险 + 伪CAS修复 + 硬编码清除 + 晚间血压
- 新增 sea_orm_ext 模块: safe_version() / bump_version() 替代 14 处 unwrap() - 修复 points_service 伪 CAS 逻辑 bug: 在 Set() 前提取原始版本并重新验证 - AdminDashboard: API 失败时显示 unknown 状态而非虚假绿色 healthy - AdminDashboard: 今日操作改用真实数据,移除 "0 错误" 硬编码 - OperatorWorkbench: 移除硬编码 "美玲",改用真实用户名 - Home.tsx: operator "内容发布" 从硬编码 0 改为真实积分统计 - 小程序体征录入: 新增晚间血压 indicator_type,映射到 evening 字段
This commit is contained in:
@@ -9,6 +9,7 @@ pub mod module;
|
||||
pub mod rbac;
|
||||
pub mod request_info;
|
||||
pub mod sanitize;
|
||||
pub mod sea_orm_ext;
|
||||
pub mod types;
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
17
crates/erp-core/src/sea_orm_ext.rs
Normal file
17
crates/erp-core/src/sea_orm_ext.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use sea_orm::ActiveValue;
|
||||
|
||||
/// 从 SeaORM ActiveValue<i32> 中安全提取 version 值。
|
||||
/// Set(v) / Unchanged(v) → 返回 v
|
||||
/// NotSet → 返回 1(首次版本号)
|
||||
/// 绝不 panic。
|
||||
pub fn safe_version(val: &ActiveValue<i32>) -> i32 {
|
||||
match val {
|
||||
ActiveValue::Set(v) | ActiveValue::Unchanged(v) => *v,
|
||||
ActiveValue::NotSet => 1,
|
||||
}
|
||||
}
|
||||
|
||||
/// 安全递增 version:基于当前值 +1,绝不 panic。
|
||||
pub fn bump_version(current: &ActiveValue<i32>) -> i32 {
|
||||
safe_version(current) + 1
|
||||
}
|
||||
Reference in New Issue
Block a user