Files
notify/backend_rust/src/entity/notification.rs
Michael Dong a98e12f286 first commit
2026-02-05 11:24:40 +08:00

62 lines
2.0 KiB
Rust

//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use super::sea_orm_active_enums::ChannelType;
use super::sea_orm_active_enums::NotificationStatus;
use super::sea_orm_active_enums::TargetType;
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "notification")]
#[sea_orm::model]
#[serde(rename_all = "camelCase")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(unique_key = "UQ_notification_recipient_target_trigger_channel")]
pub recipient_id: Uuid,
#[sea_orm(unique_key = "UQ_notification_recipient_target_trigger_channel")]
pub target_type: TargetType,
#[sea_orm(unique_key = "UQ_notification_recipient_target_trigger_channel")]
pub target_id: Uuid,
#[sea_orm(unique_key = "UQ_notification_recipient_target_trigger_channel")]
pub trigger_at: DateTimeWithTimeZone,
#[sea_orm(unique_key = "UQ_notification_recipient_target_trigger_channel")]
pub channel: ChannelType,
pub status: NotificationStatus,
pub locked_at: Option<DateTimeWithTimeZone>,
pub sent_at: Option<DateTimeWithTimeZone>,
pub read_at: Option<DateTimeWithTimeZone>,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub offset_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::delivery_log::Entity")]
DeliveryLog,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::RecipientId",
to = "super::user::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
User,
}
impl Related<super::delivery_log::Entity> for Entity {
fn to() -> RelationDef {
Relation::DeliveryLog.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}