Ver código fonte

✨ feat(models): 添加SeaORM实体模型及相关模块

陈雪 4 dias atrás
pai
commit
06f5967062

Diferenças do arquivo suprimidas por serem muito extensas
+ 691 - 6
src-tauri/Cargo.lock


+ 7 - 0
src-tauri/Cargo.toml

@@ -18,6 +18,11 @@ crate-type = ["staticlib", "cdylib", "rlib"]
 tauri-build = { version = "2", features = [] }
 
 [dependencies]
+sea-orm = { version = "1.1.0", features = [
+    "sqlx-sqlite",
+    "runtime-tokio-rustls",
+    "macros",
+] }
 tauri = { version = "2", features = [] }
 tauri-plugin-opener = "2"
 serde = { version = "1", features = ["derive"] }
@@ -26,6 +31,8 @@ tauri-plugin-store = "2"
 tauri-plugin-http = "2"
 tauri-plugin-upload = "2"
 tauri-plugin-os = "2"
+tokio = { version = "1.44.0", features = ["full"] }
+anyhow = "1.0.97"
 
 [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
 tauri-plugin-single-instance = "2"

+ 1 - 0
src-tauri/src/commands/mod.rs

@@ -0,0 +1 @@
+

+ 5 - 0
src-tauri/src/lib.rs

@@ -1,3 +1,7 @@
+mod commands;
+mod models;
+mod service;
+
 use std::vec;
 
 use tauri::{AppHandle, Manager};
@@ -13,6 +17,7 @@ pub fn run() {
         .plugin(tauri_plugin_http::init())
         .plugin(tauri_plugin_store::Builder::new().build())
         .plugin(tauri_plugin_opener::init())
+        .invoke_handler(tauri::generate_handler![commands::async_fetch])
         .run(tauri::generate_context!())
         .expect("error while running tauri application");
 }

+ 30 - 0
src-tauri/src/models/menu_cate.rs

@@ -0,0 +1,30 @@
+//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
+
+use sea_orm::entity::prelude::*;
+
+#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
+#[sea_orm(table_name = "menu_cate")]
+pub struct Model {
+    #[sea_orm(primary_key, auto_increment = true)]
+    pub id: i32,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub name: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub logo: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub local_logo: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub description: Option<String>,
+    #[sea_orm(column_type = "custom(\"DATETIME\")", nullable)]
+    pub create_time: Option<String>,
+    #[sea_orm(column_type = "custom(\"DATETIME\")", nullable)]
+    pub update_time: Option<String>,
+    pub sort: Option<i32>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub status: Option<String>,
+}
+
+#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+pub enum Relation {}
+
+impl ActiveModelBehavior for ActiveModel {}

+ 55 - 0
src-tauri/src/models/menu_commodity.rs

@@ -0,0 +1,55 @@
+//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
+
+use sea_orm::entity::prelude::*;
+
+#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
+#[sea_orm(table_name = "menu_commodity")]
+pub struct Model {
+    #[sea_orm(primary_key, auto_increment = true)]
+    pub id: i32,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub r#type: Option<String>,
+    pub merchant_id: Option<i32>,
+    pub store_id: Option<i32>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub name: Option<String>,
+    pub cate_id: Option<i32>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub goods_no: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub is_single_spec: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub logo: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub images: Option<String>,
+    pub price: Option<Decimal>,
+    pub line_price: Option<Decimal>,
+    pub stock: Option<i32>,
+    pub weight: Option<Decimal>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub coupon_ids: Option<String>,
+    pub service_time: Option<i32>,
+    pub init_sale: Option<i32>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub sale_point: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub can_use_point: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub is_member_discount: Option<String>,
+    pub sort: Option<i32>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub description: Option<String>,
+    #[sea_orm(column_type = "custom(\"DATETIME\")", nullable)]
+    pub create_time: Option<String>,
+    #[sea_orm(column_type = "custom(\"DATETIME\")", nullable)]
+    pub update_time: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub operator: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub status: Option<String>,
+}
+
+#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+pub enum Relation {}
+
+impl ActiveModelBehavior for ActiveModel {}

+ 44 - 0
src-tauri/src/models/menu_sku.rs

@@ -0,0 +1,44 @@
+//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
+
+use sea_orm::entity::prelude::*;
+
+#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
+#[sea_orm(table_name = "menu_sku")]
+pub struct Model {
+    #[sea_orm(primary_key)]
+    pub id: i32,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub sku_no: Option<String>,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub logo: Option<String>,
+    pub goods_id: i32,
+    pub stock: i32,
+    pub price: Decimal,
+    pub line_price: Decimal,
+    pub weight: Option<Decimal>,
+    #[sea_orm(column_type = "Text")]
+    pub status: String,
+}
+
+#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+pub enum Relation {
+    #[sea_orm(has_many = "super::menu_sku_spec::Entity")]
+    MenuSkuSpec,
+}
+
+impl Related<super::menu_sku_spec::Entity> for Entity {
+    fn to() -> RelationDef {
+        Relation::MenuSkuSpec.def()
+    }
+}
+
+impl Related<super::menu_spec::Entity> for Entity {
+    fn to() -> RelationDef {
+        super::menu_sku_spec::Relation::MenuSpec.def()
+    }
+    fn via() -> Option<RelationDef> {
+        Some(super::menu_sku_spec::Relation::MenuSku.def().rev())
+    }
+}
+
+impl ActiveModelBehavior for ActiveModel {}

+ 46 - 0
src-tauri/src/models/menu_sku_spec.rs

@@ -0,0 +1,46 @@
+//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
+
+use sea_orm::entity::prelude::*;
+
+#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
+#[sea_orm(table_name = "menu_sku_spec")]
+pub struct Model {
+    #[sea_orm(primary_key, auto_increment = false)]
+    pub sku_id: i32,
+    #[sea_orm(primary_key, auto_increment = false)]
+    pub spec_id: i32,
+}
+
+#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+pub enum Relation {
+    #[sea_orm(
+        belongs_to = "super::menu_sku::Entity",
+        from = "Column::SkuId",
+        to = "super::menu_sku::Column::Id",
+        on_update = "NoAction",
+        on_delete = "NoAction"
+    )]
+    MenuSku,
+    #[sea_orm(
+        belongs_to = "super::menu_spec::Entity",
+        from = "Column::SpecId",
+        to = "super::menu_spec::Column::Id",
+        on_update = "NoAction",
+        on_delete = "NoAction"
+    )]
+    MenuSpec,
+}
+
+impl Related<super::menu_sku::Entity> for Entity {
+    fn to() -> RelationDef {
+        Relation::MenuSku.def()
+    }
+}
+
+impl Related<super::menu_spec::Entity> for Entity {
+    fn to() -> RelationDef {
+        Relation::MenuSpec.def()
+    }
+}
+
+impl ActiveModelBehavior for ActiveModel {}

+ 40 - 0
src-tauri/src/models/menu_spec.rs

@@ -0,0 +1,40 @@
+//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
+
+use sea_orm::entity::prelude::*;
+
+#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
+#[sea_orm(table_name = "menu_spec")]
+pub struct Model {
+    #[sea_orm(primary_key, auto_increment = true)]
+    pub id: i32,
+    pub goods_id: i32,
+    #[sea_orm(column_type = "Text")]
+    pub name: String,
+    #[sea_orm(column_type = "Text")]
+    pub value: String,
+    #[sea_orm(column_type = "Text", nullable)]
+    pub status: Option<String>,
+}
+
+#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+pub enum Relation {
+    #[sea_orm(has_many = "super::menu_sku_spec::Entity")]
+    MenuSkuSpec,
+}
+
+impl Related<super::menu_sku_spec::Entity> for Entity {
+    fn to() -> RelationDef {
+        Relation::MenuSkuSpec.def()
+    }
+}
+
+impl Related<super::menu_sku::Entity> for Entity {
+    fn to() -> RelationDef {
+        super::menu_sku_spec::Relation::MenuSku.def()
+    }
+    fn via() -> Option<RelationDef> {
+        Some(super::menu_sku_spec::Relation::MenuSpec.def().rev())
+    }
+}
+
+impl ActiveModelBehavior for ActiveModel {}

+ 9 - 0
src-tauri/src/models/mod.rs

@@ -0,0 +1,9 @@
+//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
+
+pub mod prelude;
+
+pub mod menu_cate;
+pub mod menu_commodity;
+pub mod menu_sku;
+pub mod menu_sku_spec;
+pub mod menu_spec;

+ 7 - 0
src-tauri/src/models/prelude.rs

@@ -0,0 +1,7 @@
+//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
+
+pub use super::menu_cate::Entity as MenuCate;
+pub use super::menu_commodity::Entity as MenuCommodity;
+pub use super::menu_sku::Entity as MenuSku;
+pub use super::menu_sku_spec::Entity as MenuSkuSpec;
+pub use super::menu_spec::Entity as MenuSpec;

+ 0 - 0
src-tauri/src/service/mod.rs


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff