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() -> Router where DialysisState: axum::extract::FromRef, S: Clone + Send + Sync + 'static, { Router::new() } pub fn protected_routes() -> Router where DialysisState: axum::extract::FromRef, 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-records/{id}/complete", axum::routing::put(dialysis_handler::complete_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 { 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 } }