bazzar/crates/model/src/v4/addresses.rs
2023-06-03 13:31:57 +02:00

141 lines
4.0 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 {
"addresses"
}
}
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)]
pub struct Model {
pub id: String,
pub customer_id: Option<String>,
pub company: Option<String>,
pub first_name: Option<String>,
pub last_name: Option<String>,
pub address_1: Option<String>,
pub address_2: Option<String>,
pub city: Option<String>,
pub country_code: Option<String>,
pub province: Option<String>,
pub postal_code: Option<String>,
pub phone: Option<String>,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub deleted_at: Option<DateTimeWithTimeZone>,
pub metadata: Option<Json>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
pub enum Column {
Id,
CustomerId,
Company,
FirstName,
LastName,
Address1,
Address2,
City,
CountryCode,
Province,
PostalCode,
Phone,
CreatedAt,
UpdatedAt,
DeletedAt,
Metadata,
}
#[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 {
ClaimOrders,
Countries,
Customers,
Swaps,
}
impl ColumnTrait for Column {
type EntityName = Entity;
fn def(&self) -> ColumnDef {
match self {
Self::Id => ColumnType::String(None).def(),
Self::CustomerId => ColumnType::String(None).def().null(),
Self::Company => ColumnType::String(None).def().null(),
Self::FirstName => ColumnType::String(None).def().null(),
Self::LastName => ColumnType::String(None).def().null(),
Self::Address1 => ColumnType::String(None).def().null(),
Self::Address2 => ColumnType::String(None).def().null(),
Self::City => ColumnType::String(None).def().null(),
Self::CountryCode => ColumnType::String(None).def().null(),
Self::Province => ColumnType::String(None).def().null(),
Self::PostalCode => ColumnType::String(None).def().null(),
Self::Phone => ColumnType::String(None).def().null(),
Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(),
Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(),
Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(),
Self::Metadata => ColumnType::JsonBinary.def().null(),
}
}
}
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::ClaimOrders => Entity::has_many(super::claim_orders::Entity).into(),
Self::Countries => Entity::belongs_to(super::countries::Entity)
.from(Column::CountryCode)
.to(super::countries::Column::Iso2)
.into(),
Self::Customers => Entity::belongs_to(super::customers::Entity)
.from(Column::CustomerId)
.to(super::customers::Column::Id)
.into(),
Self::Swaps => Entity::has_many(super::swaps::Entity).into(),
}
}
}
impl Related<super::claim_orders::Entity> for Entity {
fn to() -> RelationDef {
Relation::ClaimOrders.def()
}
}
impl Related<super::countries::Entity> for Entity {
fn to() -> RelationDef {
Relation::Countries.def()
}
}
impl Related<super::customers::Entity> for Entity {
fn to() -> RelationDef {
Relation::Customers.def()
}
}
impl Related<super::swaps::Entity> for Entity {
fn to() -> RelationDef {
Relation::Swaps.def()
}
}
impl ActiveModelBehavior for ActiveModel {}