diff --git a/example/Cargo.toml b/example/Cargo.toml index 6fe7cd5..a5aeb07 100644 --- a/example/Cargo.toml +++ b/example/Cargo.toml @@ -9,5 +9,4 @@ publish = false serde = { version = "1", features = ["derive"] } rbson = "2.0" tokio = { version = "1.18.2", features = ["full"] } -mybatis = { version = "1.0.7", path = "../mybatis", features = ["debug_mode"]} -mybatis-macro = { version = "1.0.3", path = "../mybatis-macro"} \ No newline at end of file +mybatis = { path = "../mybatis", features = ["debug_mode"]} \ No newline at end of file diff --git a/example/src/lib.rs b/example/src/lib.rs index f88d974..2616370 100644 --- a/example/src/lib.rs +++ b/example/src/lib.rs @@ -1,8 +1,7 @@ #[macro_use] -extern crate mybatis_macro; +extern crate mybatis; -use mybatis::mybatis::Mybatis; -use serde::{Serialize, Deserialize}; +mod pets; #[cfg(test)] mod test { @@ -10,21 +9,4 @@ mod test { fn test() { assert_eq!(4+4, 8); } -} - -/// this is table model(see ../database.sql) - -#[derive(CRUDTable, Clone, Debug, Serialize, Deserialize)] -pub struct BizActivity { - pub id: Option, - pub name: Option, - pub pc_link: Option, - pub h5_link: Option, - pub pc_banner_img: Option, - pub h5_banner_img: Option, - pub sort: Option, - pub status: Option, - pub remark: Option, - pub version: Option, - pub delete_flag: Option, -} +} \ No newline at end of file diff --git a/example/src/pets.rs b/example/src/pets.rs index 158c705..61a2fee 100644 --- a/example/src/pets.rs +++ b/example/src/pets.rs @@ -1,6 +1,3 @@ -#[macro_use] -use mybatis; - use mybatis::{mybatis_sql::string_util::to_snake_name}; use mybatis::mybatis::Mybatis; use mybatis::crud::CRUDTable; @@ -8,6 +5,7 @@ use mybatis::snowflake::SNOWFLAKE; use serde::{Serialize, Deserialize}; +#[crud_table] #[derive(Debug, Serialize, Deserialize)] pub struct Pets { pub id: Option, @@ -16,22 +14,6 @@ pub struct Pets { pub delete_flag: Option, } -impl CRUDTable for Pets { - - fn table_name() -> String { - let type_name = std::any::type_name::(); - let mut name = type_name.to_string(); - let names: Vec<&str> = name.split("::").collect(); - name = names.get(names.len() - 1).unwrap_or(&"").to_string(); - - to_snake_name(&name) - } - - fn table_columns() -> String { - String::from("id,name,birthday,delete_flag") - } -} - #[cfg(test)] mod tests { use mybatis::crud::{Skip, CRUD}; diff --git a/mybatis-core/Cargo.toml b/mybatis-core/Cargo.toml index e079dd0..a29badb 100644 --- a/mybatis-core/Cargo.toml +++ b/mybatis-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mybatis-core" -version = "1.0.3" +version = "1.0.8" description = "mybatis core by sqlx" license = "Apache-2.0" edition = "2021" diff --git a/mybatis-macro/Cargo.toml b/mybatis-macro/Cargo.toml index 047e7d9..541f846 100644 --- a/mybatis-macro/Cargo.toml +++ b/mybatis-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mybatis-macro" -version = "1.0.3" +version = "1.0.8" description = "mybatis macro driver" authors = ["James Zow "] edition = "2021" diff --git a/mybatis-macro/src/macros/crud_table_impl.rs b/mybatis-macro/src/macros/crud_table_impl.rs index 4119f55..be5a576 100644 --- a/mybatis-macro/src/macros/crud_table_impl.rs +++ b/mybatis-macro/src/macros/crud_table_impl.rs @@ -6,7 +6,6 @@ use quote::quote; use quote::ToTokens; use syn; - ///impl CRUDTable pub(crate) fn impl_crud_driver( ast: &syn::DeriveInput, @@ -114,7 +113,7 @@ pub(crate) fn impl_crud_driver( #fields } - fn formats(driver_type: &mybatis::core::db::DriverType) -> std::collections::HashMap { + fn formats(driver_type: mybatis::core::db::DriverType) -> std::collections::HashMap { let mut m: std::collections::HashMap = std::collections::HashMap::new(); match driver_type{ mybatis::core::db::DriverType::Mysql=>{ diff --git a/mybatis-sql/Cargo.toml b/mybatis-sql/Cargo.toml index 358d1c3..0561546 100644 --- a/mybatis-sql/Cargo.toml +++ b/mybatis-sql/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mybatis-sql" -version = "1.0.3" +version = "1.0.8" edition = "2021" rust-version = "1.59.0" authors = ["James Zow "] @@ -14,8 +14,8 @@ debug_mode = [] [dependencies] once_cell = "1.9.0" -mybatis-core = { version = "1.0.3", path = "../mybatis-core" } -mybatis-macro = { version = "1.0.3", path = "../mybatis-macro" } +mybatis-core = { version = "1.0.8", path = "../mybatis-core" } +mybatis-macro = { version = "1.0.8", path = "../mybatis-macro" } #serde serde = { version = "1", features = ["derive"] } diff --git a/mybatis-tests/Cargo.toml b/mybatis-tests/Cargo.toml index bd84552..5f880f4 100644 --- a/mybatis-tests/Cargo.toml +++ b/mybatis-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mybatis-tests" -version = "1.0.3" +version = "1.0.8" edition = "2021" rust-version = "1.59.0" authors = ["James Zow "] @@ -9,6 +9,6 @@ description = "mybatis tests" publish = false [dependencies] -mybatis-core = {version = "1.0.3", path = "../mybatis-core"} -mybatis-util = {version = "1.0.3", path = "../mybatis-util"} -mybatis = {version = "1.0.4", path = "../mybatis"} +mybatis-core = {version = "1.0.8", path = "../mybatis-core"} +mybatis-util = {version = "1.0.8", path = "../mybatis-util"} +mybatis = {version = "1.0.8", path = "../mybatis"} diff --git a/mybatis-util/Cargo.toml b/mybatis-util/Cargo.toml index 9cfbffc..1cb60e8 100644 --- a/mybatis-util/Cargo.toml +++ b/mybatis-util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mybatis-util" -version = "1.0.3" +version = "1.0.8" edition = "2021" rust-version = "1.59.0" authors = ["James Zow "] diff --git a/mybatis/Cargo.toml b/mybatis/Cargo.toml index 3384dd3..3fc26ad 100644 --- a/mybatis/Cargo.toml +++ b/mybatis/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mybatis" -version = "1.0.7" +version = "1.0.8" edition = "2021" rust-version = "1.59.0" authors = ["James Zow "] @@ -38,10 +38,10 @@ runtime-async-std-native-tls = ["mybatis-core/runtime-async-std-native-tls"] format_bson = ["mybatis-core/format_bson"] [dependencies] -mybatis-util = { version = "1.0.3", path = "../mybatis-util", default-features = false} -mybatis-sql = { version = "1.0.3", path = "../mybatis-sql", default-features = false, optional = true} -mybatis-core = { version = "1.0.3", path = "../mybatis-core", default-features = false, optional = true} -mybatis-macro = { version = "1.0.3", path = "../mybatis-macro", default-features = false, optional = true} +mybatis-util = { version = "1.0.8", path = "../mybatis-util", default-features = false} +mybatis-sql = { version = "1.0.8", path = "../mybatis-sql", default-features = false, optional = true} +mybatis-core = { version = "1.0.8", path = "../mybatis-core", default-features = false, optional = true} +mybatis-macro = { version = "1.0.8", path = "../mybatis-macro", default-features = false, optional = true} ################################################################ rbson = { version = "2.0.3", features = ["uuid-0_8", "chrono-0_4"] } diff --git a/mybatis/README.md b/mybatis/README.md index ee3eb29..3bb2ec5 100644 --- a/mybatis/README.md +++ b/mybatis/README.md @@ -21,10 +21,11 @@ Summer MyBatis is an ORM framework based on rust language and mybatis framework. * Step1. Add mybatis dependency ```rust + mybatis = { version = "1.0.8"} + // other dependency serde = { version = "1", features = ["derive"] } rbson = "2.0" tokio = { version = "1.18.2", features = ["full"] } - mybatis = { version = "1.0.7"} ``` * Step2. Create a structure corresponding to the database table and map the method diff --git a/mybatis/src/lib.rs b/mybatis/src/lib.rs index e2f984b..8223440 100644 --- a/mybatis/src/lib.rs +++ b/mybatis/src/lib.rs @@ -3,6 +3,9 @@ pub extern crate mybatis_macro; #[macro_use] pub extern crate mybatis_sql; +// mapping macros +pub use mybatis_core as core; + pub use mybatis_sql::{expr, push_index, rb_html, rb_py, sql_index}; pub use mybatis_sql::ops::*; pub use mybatis_core::*;