use chrono::{DateTime, Utc};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "crm_converted_leads")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
pub created_at: Option<DateTime<Utc>>,
pub lead_id: i64,
pub converted_at: DateTime<Utc>,
pub company_id: i64,
pub contact_id: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::lead::Entity",
from = "Column::LeadId",
to = "super::lead::Column::Id"
)]
Lead,
#[sea_orm(
belongs_to = "super::company::Entity",
from = "Column::CompanyId",
to = "super::company::Column::Id"
)]
Company,
#[sea_orm(
belongs_to = "super::contact::Entity",
from = "Column::ContactId",
to = "super::contact::Column::Id"
)]
Contact,
}
impl Related<super::lead::Entity> for Entity {
fn to() -> RelationDef {
Relation::Lead.def()
}
}
impl ActiveModelBehavior for ActiveModel {}