feat(health): 日常监测后端 + 积分商城 PC 管理页面 (Chunk 3 V2 迭代)
后端 - 日常监测: - 新增 daily_monitoring 表 (血压/体重/血糖/出入量/备注) - Entity/DTO/Service/Handler 完整 CRUD - 唯一约束 (patient_id, record_date) 防重复上报 前端 - 积分商城管理 (3 页面): - PointsRuleList: 积分规则增删改 + 启用禁用 - PointsProductList: 商品管理 + 库存 + 类型筛选 - PointsOrderList: 订单列表 + 扫码核销 - API 模块 points.ts 对接 6 个管理端接口 - 侧边栏新增积分规则/商品管理/订单管理入口
This commit is contained in:
@@ -53,6 +53,7 @@ mod m20260425_00050_add_doctor_name_column;
|
||||
mod m20260425_000051_dialysis_and_lab_enhance;
|
||||
mod m20260425_000052_create_ai_tables;
|
||||
mod m20260425_000053_create_points_tables;
|
||||
mod m20260425_000054_create_daily_monitoring;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -113,6 +114,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260425_000051_dialysis_and_lab_enhance::Migration),
|
||||
Box::new(m20260425_000052_create_ai_tables::Migration),
|
||||
Box::new(m20260425_000053_create_points_tables::Migration),
|
||||
Box::new(m20260425_000054_create_daily_monitoring::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
/// V2 日常监测表: daily_monitoring — 患者每日血压/体重/血糖/出入量记录
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Alias::new("daily_monitoring"))
|
||||
.if_not_exists()
|
||||
.col(ColumnDef::new(Alias::new("id")).uuid().not_null().primary_key())
|
||||
.col(ColumnDef::new(Alias::new("tenant_id")).uuid().not_null())
|
||||
.col(ColumnDef::new(Alias::new("patient_id")).uuid().not_null())
|
||||
.col(ColumnDef::new(Alias::new("record_date")).date().not_null())
|
||||
// 晨起血压
|
||||
.col(ColumnDef::new(Alias::new("morning_bp_systolic")).integer())
|
||||
.col(ColumnDef::new(Alias::new("morning_bp_diastolic")).integer())
|
||||
// 晚间血压
|
||||
.col(ColumnDef::new(Alias::new("evening_bp_systolic")).integer())
|
||||
.col(ColumnDef::new(Alias::new("evening_bp_diastolic")).integer())
|
||||
// 体重 (Decimal 5,1)
|
||||
.col(ColumnDef::new(Alias::new("weight")).decimal().extra("CHECK(weight IS NULL OR weight >= 0)"))
|
||||
// 血糖 (Decimal 4,1)
|
||||
.col(ColumnDef::new(Alias::new("blood_sugar")).decimal().extra("CHECK(blood_sugar IS NULL OR blood_sugar >= 0)"))
|
||||
// 出入量
|
||||
.col(ColumnDef::new(Alias::new("fluid_intake")).integer())
|
||||
.col(ColumnDef::new(Alias::new("urine_output")).integer())
|
||||
// 备注
|
||||
.col(ColumnDef::new(Alias::new("notes")).text())
|
||||
// 标准字段
|
||||
.col(ColumnDef::new(Alias::new("created_at")).timestamp_with_time_zone().not_null().default(Expr::current_timestamp()))
|
||||
.col(ColumnDef::new(Alias::new("updated_at")).timestamp_with_time_zone().not_null().default(Expr::current_timestamp()))
|
||||
.col(ColumnDef::new(Alias::new("created_by")).uuid())
|
||||
.col(ColumnDef::new(Alias::new("updated_by")).uuid())
|
||||
.col(ColumnDef::new(Alias::new("deleted_at")).timestamp_with_time_zone())
|
||||
.col(ColumnDef::new(Alias::new("version")).integer().not_null().default(1))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// 唯一约束: (patient_id, record_date) — 每位患者每天最多一条记录
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.if_not_exists()
|
||||
.name("uk_daily_monitoring_patient_date")
|
||||
.table(Alias::new("daily_monitoring"))
|
||||
.col(Alias::new("patient_id"))
|
||||
.col(Alias::new("record_date"))
|
||||
.unique()
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// 索引: (tenant_id, record_date) — 按租户+日期范围查询
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.if_not_exists()
|
||||
.name("idx_daily_monitoring_tenant_date")
|
||||
.table(Alias::new("daily_monitoring"))
|
||||
.col(Alias::new("tenant_id"))
|
||||
.col(Alias::new("record_date"))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Alias::new("daily_monitoring")).if_exists().to_owned())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user