more webshop
This commit is contained in:
@@ -10,4 +10,5 @@ pub mod product_images;
|
||||
pub mod product_product_tags;
|
||||
pub mod product_tags;
|
||||
pub mod products;
|
||||
pub mod shipping_methods;
|
||||
pub mod users;
|
||||
|
||||
@@ -23,6 +23,12 @@ pub struct Model {
|
||||
pub country: Option<String>,
|
||||
#[sea_orm(column_type = "Text", nullable)]
|
||||
pub note: Option<String>,
|
||||
pub payment_method: Option<String>,
|
||||
pub carrier_code: Option<String>,
|
||||
pub carrier_name: Option<String>,
|
||||
pub shipping_cents: i64,
|
||||
pub pickup_point_id: Option<String>,
|
||||
pub pickup_point_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
||||
@@ -8,4 +8,5 @@ pub use super::product_images::Entity as ProductImages;
|
||||
pub use super::product_product_tags::Entity as ProductProductTags;
|
||||
pub use super::product_tags::Entity as ProductTags;
|
||||
pub use super::products::Entity as Products;
|
||||
pub use super::shipping_methods::Entity as ShippingMethods;
|
||||
pub use super::users::Entity as Users;
|
||||
|
||||
23
src/models/_entities/shipping_methods.rs
Normal file
23
src/models/_entities/shipping_methods.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "shipping_methods")]
|
||||
pub struct Model {
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
#[sea_orm(unique)]
|
||||
pub code: String,
|
||||
pub name: String,
|
||||
pub price_cents: i64,
|
||||
pub requires_pickup_point: bool,
|
||||
pub enabled: bool,
|
||||
pub position: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
@@ -8,3 +8,4 @@ pub mod product_tags;
|
||||
pub mod product_product_tags;
|
||||
pub mod orders;
|
||||
pub mod order_items;
|
||||
pub mod shipping_methods;
|
||||
|
||||
28
src/models/shipping_methods.rs
Normal file
28
src/models/shipping_methods.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
pub use super::_entities::shipping_methods::{ActiveModel, Model, Entity};
|
||||
pub type ShippingMethods = Entity;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl ActiveModelBehavior for ActiveModel {
|
||||
async fn before_save<C>(self, _db: &C, insert: bool) -> std::result::Result<Self, DbErr>
|
||||
where
|
||||
C: ConnectionTrait,
|
||||
{
|
||||
if !insert && self.updated_at.is_unchanged() {
|
||||
let mut this = self;
|
||||
this.updated_at = sea_orm::ActiveValue::Set(chrono::Utc::now().into());
|
||||
Ok(this)
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// implement your read-oriented logic here
|
||||
impl Model {}
|
||||
|
||||
// implement your write-oriented logic here
|
||||
impl ActiveModel {}
|
||||
|
||||
// implement your custom finders, selectors oriented logic here
|
||||
impl Entity {}
|
||||
Reference in New Issue
Block a user