- 重写全部 6 个 handler 文件,从占位错误改为调用 service 层 - 删除 handler 内联 DTO,统一使用 dto/ 模块类型 - 新增 dto/doctor_dto.rs 和 dto/follow_up_dto.rs - 新增 service/doctor_service.rs 实现医护档案 CRUD - 将 follow_up_service 内联 DTO 迁移到 dto/follow_up_dto.rs - 修复 consultation_session 列名 type→consultation_type(数据库+entity+迁移同步) - 全部 51 个 API 端点已验证可用 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
61 lines
1.8 KiB
Rust
61 lines
1.8 KiB
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "consultation_session")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub tenant_id: Uuid,
|
|
pub patient_id: Uuid,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub doctor_id: Option<Uuid>,
|
|
pub consultation_type: String,
|
|
pub status: String,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub last_message_at: Option<DateTimeUtc>,
|
|
pub unread_count_patient: i32,
|
|
pub unread_count_doctor: i32,
|
|
pub created_at: DateTimeUtc,
|
|
pub updated_at: DateTimeUtc,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub created_by: Option<Uuid>,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub updated_by: Option<Uuid>,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub deleted_at: Option<DateTimeUtc>,
|
|
pub version: i32,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::patient::Entity",
|
|
from = "Column::PatientId",
|
|
to = "super::patient::Column::Id"
|
|
)]
|
|
Patient,
|
|
#[sea_orm(
|
|
belongs_to = "super::doctor_profile::Entity",
|
|
from = "Column::DoctorId",
|
|
to = "super::doctor_profile::Column::Id"
|
|
)]
|
|
Doctor,
|
|
#[sea_orm(has_many = "super::consultation_message::Entity")]
|
|
Message,
|
|
}
|
|
|
|
impl Related<super::patient::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Patient.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::consultation_message::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Message.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|