117 lines
3.2 KiB
Rust
117 lines
3.2 KiB
Rust
|
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
|
||
|
|
||
|
use sea_orm::entity::prelude::*;
|
||
|
use serde::{Deserialize, Serialize};
|
||
|
|
||
|
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
|
||
|
pub struct Entity;
|
||
|
|
||
|
impl EntityName for Entity {
|
||
|
fn table_name(&self) -> &str {
|
||
|
"notifications"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)]
|
||
|
pub struct Model {
|
||
|
pub id: String,
|
||
|
pub event_name: Option<String>,
|
||
|
pub resource_type: String,
|
||
|
pub resource_id: String,
|
||
|
pub customer_id: Option<String>,
|
||
|
pub to: String,
|
||
|
pub data: Json,
|
||
|
pub parent_id: Option<String>,
|
||
|
pub provider_id: Option<String>,
|
||
|
pub created_at: DateTimeWithTimeZone,
|
||
|
pub updated_at: DateTimeWithTimeZone,
|
||
|
}
|
||
|
|
||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
||
|
pub enum Column {
|
||
|
Id,
|
||
|
EventName,
|
||
|
ResourceType,
|
||
|
ResourceId,
|
||
|
CustomerId,
|
||
|
To,
|
||
|
Data,
|
||
|
ParentId,
|
||
|
ProviderId,
|
||
|
CreatedAt,
|
||
|
UpdatedAt,
|
||
|
}
|
||
|
|
||
|
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
||
|
pub enum PrimaryKey {
|
||
|
Id,
|
||
|
}
|
||
|
|
||
|
impl PrimaryKeyTrait for PrimaryKey {
|
||
|
type ValueType = String;
|
||
|
fn auto_increment() -> bool {
|
||
|
false
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||
|
pub enum Relation {
|
||
|
Customers,
|
||
|
NotificationProviders,
|
||
|
SelfRef,
|
||
|
}
|
||
|
|
||
|
impl ColumnTrait for Column {
|
||
|
type EntityName = Entity;
|
||
|
fn def(&self) -> ColumnDef {
|
||
|
match self {
|
||
|
Self::Id => ColumnType::String(None).def(),
|
||
|
Self::EventName => ColumnType::String(None).def().null(),
|
||
|
Self::ResourceType => ColumnType::String(None).def(),
|
||
|
Self::ResourceId => ColumnType::String(None).def(),
|
||
|
Self::CustomerId => ColumnType::String(None).def().null(),
|
||
|
Self::To => ColumnType::String(None).def(),
|
||
|
Self::Data => ColumnType::JsonBinary.def(),
|
||
|
Self::ParentId => ColumnType::String(None).def().null(),
|
||
|
Self::ProviderId => ColumnType::String(None).def().null(),
|
||
|
Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(),
|
||
|
Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl RelationTrait for Relation {
|
||
|
fn def(&self) -> RelationDef {
|
||
|
match self {
|
||
|
Self::Customers => Entity::belongs_to(super::customers::Entity)
|
||
|
.from(Column::CustomerId)
|
||
|
.to(super::customers::Column::Id)
|
||
|
.into(),
|
||
|
Self::NotificationProviders => {
|
||
|
Entity::belongs_to(super::notification_providers::Entity)
|
||
|
.from(Column::ProviderId)
|
||
|
.to(super::notification_providers::Column::Id)
|
||
|
.into()
|
||
|
}
|
||
|
Self::SelfRef => Entity::belongs_to(Entity)
|
||
|
.from(Column::ParentId)
|
||
|
.to(Column::Id)
|
||
|
.into(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl Related<super::customers::Entity> for Entity {
|
||
|
fn to() -> RelationDef {
|
||
|
Relation::Customers.def()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl Related<super::notification_providers::Entity> for Entity {
|
||
|
fn to() -> RelationDef {
|
||
|
Relation::NotificationProviders.def()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl ActiveModelBehavior for ActiveModel {}
|