use sea_orm::JsonValue; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum WebhookStatus { #[default] #[sea_orm(num_value = 0)] Active, #[sea_orm(num_value = 1)] Disabled, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[sea_orm(table_name = "webhook")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub url: String, // 敏感字段:必须在应用层加密后再落库,且响应中禁止回显明文 pub secret: String, pub status: WebhookStatus, pub events: JsonValue, pub space_id: Option, pub created_by: i64, pub created_at: OffsetDateTime, pub updated_at: Option, #[sea_orm(belongs_to, from = "created_by", to = "uid")] pub creator: BelongsTo, #[sea_orm(belongs_to, from = "space_id", to = "id")] pub space: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}