From ac8d300dc05dd4280be9dac9c82fe28c2211b77a Mon Sep 17 00:00:00 2001 From: iven Date: Mon, 11 May 2026 13:05:11 +0800 Subject: [PATCH] =?UTF-8?q?docs(health):=20OpenAPI=20=E6=B3=A8=E8=A7=A3=20?= =?UTF-8?q?=E2=80=94=20device=5Fhandler=20+=20consent=5Fhandler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为 device_handler (2 函数) 和 consent_handler (3 函数) 添加 #[utoipa::path] 注解。P1-5 批次 1/N。 --- .../erp-health/src/handler/consent_handler.rs | 23 ++++++++++++++++++- .../erp-health/src/handler/device_handler.rs | 20 ++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/erp-health/src/handler/consent_handler.rs b/crates/erp-health/src/handler/consent_handler.rs index cef5969..b66572e 100644 --- a/crates/erp-health/src/handler/consent_handler.rs +++ b/crates/erp-health/src/handler/consent_handler.rs @@ -9,12 +9,19 @@ use crate::dto::consent_dto::*; use crate::service::consent_service; use crate::state::HealthState; -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, utoipa::IntoParams)] pub struct ConsentListParams { pub page: Option, pub page_size: Option, } +#[utoipa::path( + get, + path = "/health/patients/{patient_id}/consents", + responses((status = 200, description = "知情同意列表")), + tag = "知情同意", + security(("bearer_auth" = [])), +)] pub async fn list_consents( State(state): State, Extension(ctx): Extension, @@ -33,6 +40,13 @@ where Ok(Json(ApiResponse::ok(result))) } +#[utoipa::path( + post, + path = "/health/consents", + responses((status = 200, description = "授权成功")), + tag = "知情同意", + security(("bearer_auth" = [])), +)] pub async fn grant_consent( State(state): State, Extension(ctx): Extension, @@ -50,6 +64,13 @@ where Ok(Json(ApiResponse::ok(result))) } +#[utoipa::path( + put, + path = "/health/consents/{consent_id}/revoke", + responses((status = 200, description = "撤销成功")), + tag = "知情同意", + security(("bearer_auth" = [])), +)] pub async fn revoke_consent( State(state): State, Extension(ctx): Extension, diff --git a/crates/erp-health/src/handler/device_handler.rs b/crates/erp-health/src/handler/device_handler.rs index fb18e7a..0cb8095 100644 --- a/crates/erp-health/src/handler/device_handler.rs +++ b/crates/erp-health/src/handler/device_handler.rs @@ -27,6 +27,16 @@ pub struct DeviceListQuery { } /// GET /api/v1/health/devices — 设备绑定列表 +#[utoipa::path( + get, + path = "/health/devices", + params(DeviceListQuery), + responses( + (status = 200, description = "设备列表"), + ), + tag = "设备管理", + security(("bearer_auth" = [])), +)] pub async fn list_devices( State(state): State, Extension(ctx): Extension, @@ -60,6 +70,16 @@ where } /// DELETE /api/v1/health/devices/{id} — 解绑设备(软删除) +#[utoipa::path( + delete, + path = "/health/devices/{id}", + responses( + (status = 200, description = "解绑成功"), + (status = 404, description = "设备不存在"), + ), + tag = "设备管理", + security(("bearer_auth" = [])), +)] pub async fn unbind_device( State(state): State, Extension(ctx): Extension,