bazzar/crates/model/src/v4/shipping_tax_rates.rs

93 lines
2.3 KiB
Rust
Raw Normal View History

2023-06-03 13:31:57 +02:00
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
2023-06-12 15:11:59 +02:00
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
pub struct Entity;
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
impl EntityName for Entity {
fn table_name(&self) -> &str {
"shipping_tax_rates"
}
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)]
pub struct Model {
pub shipping_option_id: String,
pub rate_id: String,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub metadata: Option<Json>,
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
pub enum Column {
ShippingOptionId,
RateId,
CreatedAt,
UpdatedAt,
Metadata,
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
pub enum PrimaryKey {
ShippingOptionId,
RateId,
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
impl PrimaryKeyTrait for PrimaryKey {
type ValueType = (String, String);
fn auto_increment() -> bool {
false
}
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
ShippingOptions,
TaxRates,
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
impl ColumnTrait for Column {
type EntityName = Entity;
fn def(&self) -> ColumnDef {
match self {
Self::ShippingOptionId => ColumnType::String(None).def(),
Self::RateId => ColumnType::String(None).def(),
Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(),
Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(),
Self::Metadata => ColumnType::JsonBinary.def().null(),
}
}
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::ShippingOptions => Entity::belongs_to(super::shipping_options::Entity)
.from(Column::ShippingOptionId)
.to(super::shipping_options::Column::Id)
.into(),
Self::TaxRates => Entity::belongs_to(super::tax_rates::Entity)
.from(Column::RateId)
.to(super::tax_rates::Column::Id)
.into(),
}
}
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
impl Related<super::shipping_options::Entity> for Entity {
fn to() -> RelationDef {
Relation::ShippingOptions.def()
}
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
impl Related<super::tax_rates::Entity> for Entity {
fn to() -> RelationDef {
Relation::TaxRates.def()
}
}
2023-06-03 13:31:57 +02:00
2023-06-12 15:11:59 +02:00
impl ActiveModelBehavior for ActiveModel {}