protected_routes (800+ 行) 按业务域拆分为 routes/ 目录下 13 个文件: patient / health_data / follow_up / appointment / consultation / article / points / stats / alert / device / media / care / admin。 module.rs 从 1595 行降至 798 行,路由注册逻辑更清晰。
132 lines
5.0 KiB
Rust
132 lines
5.0 KiB
Rust
use axum::Router;
|
||
|
||
use crate::handler::{
|
||
daily_monitoring_handler, diagnosis_handler, health_data_handler, medication_record_handler,
|
||
medication_reminder_handler, vital_signs_daily_handler,
|
||
};
|
||
|
||
pub fn routes<S>() -> Router<S>
|
||
where
|
||
crate::state::HealthState: axum::extract::FromRef<S>,
|
||
S: Clone + Send + Sync + 'static,
|
||
{
|
||
Router::new()
|
||
// 健康数据
|
||
.route(
|
||
"/health/patients/{id}/vital-signs",
|
||
axum::routing::get(health_data_handler::list_vital_signs)
|
||
.post(health_data_handler::create_vital_signs),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/vital-signs/{vid}",
|
||
axum::routing::put(health_data_handler::update_vital_signs)
|
||
.delete(health_data_handler::delete_vital_signs),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/lab-reports",
|
||
axum::routing::get(health_data_handler::list_lab_reports)
|
||
.post(health_data_handler::create_lab_report),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/lab-reports/{rid}",
|
||
axum::routing::put(health_data_handler::update_lab_report)
|
||
.delete(health_data_handler::delete_lab_report),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/lab-reports/{rid}/review",
|
||
axum::routing::put(health_data_handler::review_lab_report),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/health-records",
|
||
axum::routing::get(health_data_handler::list_health_records)
|
||
.post(health_data_handler::create_health_record),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/health-records/{rid}",
|
||
axum::routing::put(health_data_handler::update_health_record)
|
||
.delete(health_data_handler::delete_health_record),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/trends",
|
||
axum::routing::get(health_data_handler::list_trends),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/trends/generate",
|
||
axum::routing::post(health_data_handler::generate_trend),
|
||
)
|
||
.route(
|
||
"/health/patients/{id}/trends/{indicator}",
|
||
axum::routing::get(health_data_handler::get_indicator_timeseries),
|
||
)
|
||
// 小程序趋势查询(通过 JWT user_id 关联 patient,无需传 patient_id)
|
||
.route(
|
||
"/health/vital-signs/trend",
|
||
axum::routing::get(health_data_handler::get_mini_trend),
|
||
)
|
||
// 小程序今日体征摘要
|
||
.route(
|
||
"/health/vital-signs/today",
|
||
axum::routing::get(health_data_handler::get_mini_today),
|
||
)
|
||
// 日聚合查询
|
||
.route(
|
||
"/health/vital-signs/daily",
|
||
axum::routing::get(vital_signs_daily_handler::get_daily_aggregations),
|
||
)
|
||
// 日常监测
|
||
.route(
|
||
"/health/patients/{id}/daily-monitoring",
|
||
axum::routing::get(daily_monitoring_handler::list_daily_monitoring),
|
||
)
|
||
.route(
|
||
"/health/daily-monitoring",
|
||
axum::routing::post(daily_monitoring_handler::create_daily_monitoring),
|
||
)
|
||
.route(
|
||
"/health/daily-monitoring/{id}",
|
||
axum::routing::get(daily_monitoring_handler::get_daily_monitoring)
|
||
.put(daily_monitoring_handler::update_daily_monitoring)
|
||
.delete(daily_monitoring_handler::delete_daily_monitoring),
|
||
)
|
||
// 诊断记录
|
||
.route(
|
||
"/health/patients/{id}/diagnoses",
|
||
axum::routing::get(diagnosis_handler::list_diagnoses)
|
||
.post(diagnosis_handler::create_diagnosis),
|
||
)
|
||
.route(
|
||
"/health/diagnoses/{id}",
|
||
axum::routing::put(diagnosis_handler::update_diagnosis)
|
||
.delete(diagnosis_handler::delete_diagnosis),
|
||
)
|
||
// 用药记录
|
||
.route(
|
||
"/health/patients/{id}/medications",
|
||
axum::routing::get(medication_record_handler::list_medications),
|
||
)
|
||
.route(
|
||
"/health/medications",
|
||
axum::routing::post(medication_record_handler::create_medication),
|
||
)
|
||
.route(
|
||
"/health/medications/{id}",
|
||
axum::routing::get(medication_record_handler::get_medication)
|
||
.put(medication_record_handler::update_medication)
|
||
.delete(medication_record_handler::delete_medication),
|
||
)
|
||
// 药物提醒 CRUD
|
||
.route(
|
||
"/health/patients/{id}/medication-reminders",
|
||
axum::routing::get(medication_reminder_handler::list_reminders),
|
||
)
|
||
.route(
|
||
"/health/medication-reminders",
|
||
axum::routing::post(medication_reminder_handler::create_reminder),
|
||
)
|
||
.route(
|
||
"/health/medication-reminders/{id}",
|
||
axum::routing::put(medication_reminder_handler::update_reminder)
|
||
.delete(medication_reminder_handler::delete_reminder),
|
||
)
|
||
}
|