Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
mybatis = { path = "../mybatis", features = ["debug_mode"]}
24 changes: 3 additions & 21 deletions example/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
#[macro_use]
extern crate mybatis_macro;
extern crate mybatis;

use mybatis::mybatis::Mybatis;
use serde::{Serialize, Deserialize};
mod pets;

#[cfg(test)]
mod test {
#[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<String>,
pub name: Option<String>,
pub pc_link: Option<String>,
pub h5_link: Option<String>,
pub pc_banner_img: Option<String>,
pub h5_banner_img: Option<String>,
pub sort: Option<String>,
pub status: Option<i32>,
pub remark: Option<String>,
pub version: Option<i64>,
pub delete_flag: Option<i32>,
}
}
20 changes: 1 addition & 19 deletions example/src/pets.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#[macro_use]
use mybatis;

use mybatis::{mybatis_sql::string_util::to_snake_name};
use mybatis::mybatis::Mybatis;
use mybatis::crud::CRUDTable;
use mybatis::snowflake::SNOWFLAKE;
use serde::{Serialize, Deserialize};


#[crud_table]
#[derive(Debug, Serialize, Deserialize)]
pub struct Pets {
pub id: Option<String>,
Expand All @@ -16,22 +14,6 @@ pub struct Pets {
pub delete_flag: Option<i32>,
}

impl CRUDTable for Pets {

fn table_name() -> String {
let type_name = std::any::type_name::<Self>();
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};
Expand Down
2 changes: 1 addition & 1 deletion mybatis-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion mybatis-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mybatis-macro"
version = "1.0.3"
version = "1.0.8"
description = "mybatis macro driver"
authors = ["James Zow <jameszow@163.com>"]
edition = "2021"
Expand Down
3 changes: 1 addition & 2 deletions mybatis-macro/src/macros/crud_table_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use quote::quote;
use quote::ToTokens;
use syn;


///impl CRUDTable
pub(crate) fn impl_crud_driver(
ast: &syn::DeriveInput,
Expand Down Expand Up @@ -114,7 +113,7 @@ pub(crate) fn impl_crud_driver(
#fields
}

fn formats(driver_type: &mybatis::core::db::DriverType) -> std::collections::HashMap<String, String> {
fn formats(driver_type: mybatis::core::db::DriverType) -> std::collections::HashMap<String, String> {
let mut m: std::collections::HashMap<String, String> = std::collections::HashMap::new();
match driver_type{
mybatis::core::db::DriverType::Mysql=>{
Expand Down
6 changes: 3 additions & 3 deletions mybatis-sql/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <Jameszow@163.com>"]
Expand All @@ -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"] }
Expand Down
8 changes: 4 additions & 4 deletions mybatis-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <Jameszow@163.com>"]
Expand All @@ -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"}
2 changes: 1 addition & 1 deletion mybatis-util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <Jameszow@163.com>"]
Expand Down
10 changes: 5 additions & 5 deletions mybatis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <Jameszow@163.com>"]
Expand Down Expand Up @@ -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"] }
Expand Down
3 changes: 2 additions & 1 deletion mybatis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions mybatis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down