新增随访模板和模板字段两张表及完整 CRUD: - 迁移 083: follow_up_template + follow_up_template_field - Entity: 模板(名称/类型/适用范围/状态) + 字段(标签/键名/类型/选项/校验) - DTO: 创建时内嵌字段列表、更新支持全量替换字段 - Service: 随访类型+字段类型校验、级联软删除 - Handler: 5 端点 + RBAC 权限 - 路由: /api/v1/health/follow-up-templates
55 lines
1.8 KiB
Rust
55 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 = "follow_up_template_field")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub tenant_id: Uuid,
|
|
pub template_id: Uuid,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub label: String,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub field_key: String,
|
|
// text/number/date/select/checkbox/textarea/scale
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub field_type: String,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub required: bool,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub options: Option<String>,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub placeholder: Option<String>,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub validation: Option<String>,
|
|
pub sort_order: 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::follow_up_template::Entity",
|
|
from = "Column::TemplateId",
|
|
to = "super::follow_up_template::Column::Id"
|
|
)]
|
|
Template,
|
|
}
|
|
|
|
impl Related<super::follow_up_template::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Template.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|