first commit
This commit is contained in:
61
backend_rust/src/entity/notification.rs
Normal file
61
backend_rust/src/entity/notification.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
//! `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 {}
|
||||
Reference in New Issue
Block a user