Files
hms/crates/erp-dialysis/src/module.rs
iven 30a578ee00
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled
fix(health): 客户试用前全局审计修复 — P0 权限旁路 + API 路径 + 事件注册
P0 阻塞修复:
- 修复 PrivateRoute 权限旁路: p.startsWith('auth.') 匹配不到任何权限码,
  改为基于实际权限码的路由级检查 (user.manage/role.manage/organization.manage)
- 修复 deviceReadings API 路径: /patients/{id}/device-readings/daily 改为
  /vital-signs/daily?patient_id=, 消除 404

P1 重要修复:
- 补全事件注册表: 新增 auth(11) + config(8) + workflow(4) + plugin(2) = 25 条
- article_article_tag 联表新增 tenant_id + deleted_at + 审计列 (迁移 107)
- vital_signs_hourly 新增 deleted_at 支持软删除过滤 (迁移 108)
- 6 个页面添加权限守卫 (AlertDashboard/AlertRuleList/DeviceManage/
  AiAnalysisList/AiUsageDashboard)
- DialysisModule 声明 auth 依赖
2026-05-04 11:02:25 +08:00

130 lines
4.3 KiB
Rust

use async_trait::async_trait;
use axum::Router;
use erp_core::error::AppResult;
use erp_core::module::{ErpModule, ModuleContext, ModuleType, PermissionDescriptor};
use crate::handler::{dialysis_handler, dialysis_prescription_handler, dialysis_stats_handler};
use crate::state::DialysisState;
pub struct DialysisModule;
impl DialysisModule {
pub fn public_routes<S>() -> Router<S>
where
DialysisState: axum::extract::FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Router::new()
}
pub fn protected_routes<S>() -> Router<S>
where
DialysisState: axum::extract::FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Router::new()
// 透析记录
.route(
"/health/patients/{id}/dialysis-records",
axum::routing::get(dialysis_handler::list_dialysis_records),
)
.route(
"/health/dialysis-records",
axum::routing::post(dialysis_handler::create_dialysis_record),
)
.route(
"/health/dialysis-records/{id}",
axum::routing::get(dialysis_handler::get_dialysis_record)
.put(dialysis_handler::update_dialysis_record)
.delete(dialysis_handler::delete_dialysis_record),
)
.route(
"/health/dialysis-records/{id}/review",
axum::routing::put(dialysis_handler::review_dialysis_record),
)
// 透析方案
.route(
"/health/dialysis-prescriptions",
axum::routing::get(dialysis_prescription_handler::list_prescriptions)
.post(dialysis_prescription_handler::create_prescription),
)
.route(
"/health/dialysis-prescriptions/{id}",
axum::routing::get(dialysis_prescription_handler::get_prescription)
.put(dialysis_prescription_handler::update_prescription)
.delete(dialysis_prescription_handler::delete_prescription),
)
// 透析统计
.route(
"/health/admin/statistics/dialysis",
axum::routing::get(dialysis_stats_handler::get_dialysis_stats),
)
}
}
#[async_trait]
impl ErpModule for DialysisModule {
fn name(&self) -> &str {
"透析管理"
}
fn id(&self) -> &str {
"erp-dialysis"
}
fn version(&self) -> &str {
"0.1.0"
}
fn module_type(&self) -> ModuleType {
ModuleType::Builtin
}
fn dependencies(&self) -> Vec<&str> {
vec!["auth"]
}
fn permissions(&self) -> Vec<PermissionDescriptor> {
vec![
PermissionDescriptor {
code: "health.dialysis.list".into(),
name: "查看透析记录".into(),
description: "查看透析记录列表和详情".into(),
module: "erp-dialysis".into(),
},
PermissionDescriptor {
code: "health.dialysis.manage".into(),
name: "管理透析记录".into(),
description: "创建、编辑、审阅、删除透析记录".into(),
module: "erp-dialysis".into(),
},
PermissionDescriptor {
code: "health.dialysis-prescription.list".into(),
name: "查看透析处方".into(),
description: "查看透析处方列表和详情".into(),
module: "erp-dialysis".into(),
},
PermissionDescriptor {
code: "health.dialysis-prescription.manage".into(),
name: "管理透析处方".into(),
description: "创建、编辑、删除透析处方".into(),
module: "erp-dialysis".into(),
},
PermissionDescriptor {
code: "health.dialysis.stats".into(),
name: "查看透析统计".into(),
description: "查看透析统计数据".into(),
module: "erp-dialysis".into(),
},
]
}
async fn on_startup(&self, _ctx: &ModuleContext) -> AppResult<()> {
Ok(())
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
}