Skip to content
Clone
7b02b53
40 lines 1.2 KB Rust
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<Uuid>,
pub created_by: Uuid,
pub created_at: OffsetDateTime,
pub updated_at: Option<OffsetDateTime>,
#[sea_orm(belongs_to, from = "created_by", to = "uid")]
pub creator: BelongsTo<super::super::users::user::Entity>,
#[sea_orm(belongs_to, from = "space_id", to = "id")]
pub space: BelongsTo<Option<super::super::space::spaces::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}