修正 spec review 发现的问题: - C-1: TestDb 实际是本地 PostgreSQL 隔离,非 Testcontainers - C-2: E2E 已有 4 spec/10 测试,非零测试 - 补充 6 个遗漏的 service(alert/daily_monitoring/critical_value_threshold 等) - 增加 Phase 0 基础设施搭建 - 修正 CI 配置(增加 PostgreSQL service、验证链) - 补充 5 个遗漏风险项和回退策略 - 统一"全量 80%"目标的准确含义
59 lines
1.7 KiB
Rust
59 lines
1.7 KiB
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "alerts")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub tenant_id: Uuid,
|
|
pub patient_id: Uuid,
|
|
pub rule_id: Uuid,
|
|
pub severity: String,
|
|
pub title: String,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub detail: Option<serde_json::Value>,
|
|
pub status: String,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub acknowledged_by: Option<Uuid>,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub acknowledged_at: Option<DateTimeUtc>,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub resolved_at: Option<DateTimeUtc>,
|
|
pub created_at: DateTimeUtc,
|
|
pub updated_at: DateTimeUtc,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub deleted_at: Option<DateTimeUtc>,
|
|
pub version: i32,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::alert_rules::Entity",
|
|
from = "Column::RuleId",
|
|
to = "super::alert_rules::Column::Id"
|
|
)]
|
|
AlertRule,
|
|
#[sea_orm(
|
|
belongs_to = "super::patient::Entity",
|
|
from = "Column::PatientId",
|
|
to = "super::patient::Column::Id"
|
|
)]
|
|
Patient,
|
|
}
|
|
|
|
impl Related<super::alert_rules::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::AlertRule.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::patient::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Patient.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|