安全审计修复: - 补全 6 个 DTO 的 sanitize 方法(diagnosis/consent/alert/medication_record/medication_reminder/follow_up_template) - 4 个 handler 添加 .sanitize() 调用(diagnosis/consent/alert_rule/medication_record) - 修复咨询消息 sender_id/sender_role 从客户端提交改为服务端从 JWT 提取 - 修复小程序 AI 报告 markdownToHtml XSS(添加 sanitizeHtml 过滤)
64 lines
1.8 KiB
Rust
64 lines
1.8 KiB
Rust
use erp_core::sanitize::sanitize_string;
|
||
use serde::{Deserialize, Serialize};
|
||
use utoipa::ToSchema;
|
||
use uuid::Uuid;
|
||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||
pub struct SessionResp {
|
||
pub id: Uuid,
|
||
pub patient_id: Uuid,
|
||
pub doctor_id: Option<Uuid>,
|
||
pub patient_name: Option<String>,
|
||
pub doctor_name: Option<String>,
|
||
pub consultation_type: String,
|
||
pub status: String,
|
||
pub last_message_at: Option<chrono::DateTime<chrono::Utc>>,
|
||
pub unread_count_patient: i32,
|
||
pub unread_count_doctor: i32,
|
||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||
pub updated_at: chrono::DateTime<chrono::Utc>,
|
||
pub version: i32,
|
||
}
|
||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||
pub struct MessageResp {
|
||
pub id: Uuid,
|
||
pub session_id: Uuid,
|
||
pub sender_id: Uuid,
|
||
pub sender_role: String,
|
||
pub content_type: String,
|
||
pub content: String,
|
||
pub is_read: bool,
|
||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||
}
|
||
|
||
/// 发送消息请求体 — 不含 sender_id/sender_role,由服务端从 JWT 注入。
|
||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||
pub struct CreateMessageReq {
|
||
pub session_id: Uuid,
|
||
pub content_type: Option<String>,
|
||
pub content: String,
|
||
}
|
||
|
||
impl CreateMessageReq {
|
||
pub fn sanitize(&mut self) {
|
||
self.content = sanitize_string(&self.content);
|
||
}
|
||
}
|
||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||
pub struct CreateSessionReq {
|
||
pub patient_id: Uuid,
|
||
pub doctor_id: Option<Uuid>,
|
||
pub consultation_type: Option<String>,
|
||
}
|
||
|
||
#[derive(Debug, Clone, Deserialize, utoipa::IntoParams)]
|
||
pub struct SessionQuery {
|
||
pub status: Option<String>,
|
||
pub patient_id: Option<Uuid>,
|
||
pub doctor_id: Option<Uuid>,
|
||
pub page: Option<u64>,
|
||
pub page_size: Option<u64>,
|
||
}
|