diff --git a/docs/assets/images/comments/01.png b/docs/assets/images/comments/01.png new file mode 100644 index 00000000..e7abda39 Binary files /dev/null and b/docs/assets/images/comments/01.png differ diff --git a/docs/assets/images/comments/02.png b/docs/assets/images/comments/02.png new file mode 100644 index 00000000..03f1dda1 Binary files /dev/null and b/docs/assets/images/comments/02.png differ diff --git a/docs/assets/images/comments/03.png b/docs/assets/images/comments/03.png new file mode 100644 index 00000000..bed7ecb1 Binary files /dev/null and b/docs/assets/images/comments/03.png differ diff --git a/docs/assets/images/comments/04.png b/docs/assets/images/comments/04.png new file mode 100644 index 00000000..b0695054 Binary files /dev/null and b/docs/assets/images/comments/04.png differ diff --git a/docs/assets/images/comments/05.png b/docs/assets/images/comments/05.png new file mode 100644 index 00000000..fd7ff50a Binary files /dev/null and b/docs/assets/images/comments/05.png differ diff --git a/docs/index.md b/docs/index.md index 587f379c..a25c6423 100644 --- a/docs/index.md +++ b/docs/index.md @@ -13,8 +13,8 @@ hero: text: 快速开始 link: /zh/getting-started - theme: alt - text: 在 Gitee 上查看 - link: https://gitee.com/mybatis-flex/mybatis-flex + text: Mybatis-Flex 是什么 + link: /zh/what-is-mybatisflex features: - title: 更轻量 diff --git a/docs/zh/getting-started.md b/docs/zh/getting-started.md index f576e0e4..02f7fc42 100644 --- a/docs/zh/getting-started.md +++ b/docs/zh/getting-started.md @@ -1,5 +1,10 @@ # 快速开始 +在开始之前,我们假定您已经: + +- 熟悉 Java 开发和及其环境配置 +- 熟悉 关系型 数据库,比如 MySql + ## Hello World **第 1 步:创建数据库表** @@ -38,10 +43,10 @@ public class Account { //getter setter } ``` -- `@Table("tb_account")` 设置实体类与表名的映射关系 -- `@Id(keyType = KeyType.Auto)` 标识主键为自增 +- 使用 `@Table("tb_account")` 设置实体类与表名的映射关系 +- 使用 `@Id(keyType = KeyType.Auto)` 标识主键为自增 -**第 4 步:编写一个 main 方法开始使用** +**第 4 步:通过 main 方法开始使用(无 Spring 的场景)** ```java public class HelloWorld { diff --git a/docs/zh/what-is-mybatisflex.md b/docs/zh/what-is-mybatisflex.md index 5f79e6d9..d14000fc 100644 --- a/docs/zh/what-is-mybatisflex.md +++ b/docs/zh/what-is-mybatisflex.md @@ -20,4 +20,25 @@ QueryWrapper 帮助我们极大的减少了 SQL 编写的工作的同时,减 **数据填充** 等等功能。 +## 一些评价 + + +![](../assets/images/comments/01.png) + +--- + +![](../assets/images/comments/02.png) + +--- + +![](../assets/images/comments/03.png) + +--- + +![](../assets/images/comments/04.png) + +--- + +![](../assets/images/comments/05.png) + diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java index a479ec9f..cd494455 100644 --- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java @@ -16,11 +16,15 @@ package com.mybatisflex.test; import com.mybatisflex.core.MybatisFlexBootstrap; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.util.UpdateEntity; import org.apache.ibatis.logging.stdout.StdOutImpl; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import javax.sql.DataSource; +import java.util.*; public class EntityTestStarter { @@ -43,92 +47,92 @@ public class EntityTestStarter { accountMapper.selectOneById(1)); System.out.println(account); -// -// List allAccount = bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.selectListByQuery(QueryWrapper.create())); -// System.out.println(allAccount); -// -// -// Account newAccount = new Account(); -// newAccount.setUserName("lisi"); -// newAccount.setAge(18); -// newAccount.setBirthday(new Date()); -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.insert(newAccount)); -// -// //新增后自动回填主键 -// System.out.println("newAccount.id >>>>>> " + newAccount.getId()); -// -// -// List newAccountList = new ArrayList<>(); -// for (int i = 0; i < 5; i++) { -// Account insertAccount = new Account(); -// insertAccount.setUserName("new_user_" + i); -// insertAccount.setAge(22); -// insertAccount.setBirthday(new Date()); -// newAccountList.add(insertAccount); -// } -// -// //批量插入数据 -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.insertBatch(newAccountList)); -// -// -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.deleteById(1)); -// -// -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.deleteBatchByIds(Arrays.asList(1, 2, 3))); -// -// -// Map where = new HashMap<>(); -// where.put("id", 2); -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.deleteByMap(where)); -// -// -// Account updateAccount1 = UpdateEntity.wrap(Account.class); -// updateAccount1.setId(5L); -// updateAccount1.setUserName(null); -// updateAccount1.setAge(60); -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.update(updateAccount1, false)); -// -// -// Account updateAccount2 = UpdateEntity.wrap(Account.class); -// updateAccount2.setId(6L); -// updateAccount2.setAge(40); -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.update(updateAccount2)); -// -// -// List allAccounts = bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.selectListByQuery(QueryWrapper.create())); -// System.out.println(allAccounts); //count 5 -// -// -// //分页查询,第 2 页,每页 3 条数据 -// Page accountPage = bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.paginate(2, 3, QueryWrapper.create())); -// System.out.println(accountPage); -// -// -// Account optionsAccount = new Account(); -// optionsAccount.setUserName("optionstest"); -// optionsAccount.addOption("c1", 11); -// optionsAccount.addOption("c2", "zhang"); -// optionsAccount.addOption("c3", new Date()); -// -// -// bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.insert(optionsAccount)); -// System.out.println(">>>>>>> optionsAccount: " + optionsAccount.getId()); -// -// -// Account selectOptionsAccount = bootstrap.execute(AccountMapper.class, accountMapper -> -// accountMapper.selectOneById(optionsAccount.getId())); -// System.out.println(selectOptionsAccount); + + List allAccount = bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.selectListByQuery(QueryWrapper.create())); + System.out.println(allAccount); + + + Account newAccount = new Account(); + newAccount.setUserName("lisi"); + newAccount.setAge(18); + newAccount.setBirthday(new Date()); + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.insert(newAccount)); + + //新增后自动回填主键 + System.out.println("newAccount.id >>>>>> " + newAccount.getId()); + + + List newAccountList = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + Account insertAccount = new Account(); + insertAccount.setUserName("new_user_" + i); + insertAccount.setAge(22); + insertAccount.setBirthday(new Date()); + newAccountList.add(insertAccount); + } + + //批量插入数据 + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.insertBatch(newAccountList)); + + + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.deleteById(1)); + + + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.deleteBatchByIds(Arrays.asList(1, 2, 3))); + + + Map where = new HashMap<>(); + where.put("id", 2); + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.deleteByMap(where)); + + + Account updateAccount1 = UpdateEntity.wrap(Account.class); + updateAccount1.setId(5L); + updateAccount1.setUserName(null); + updateAccount1.setAge(60); + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.update(updateAccount1, false)); + + + Account updateAccount2 = UpdateEntity.wrap(Account.class); + updateAccount2.setId(6L); + updateAccount2.setAge(40); + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.update(updateAccount2)); + + + List allAccounts = bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.selectListByQuery(QueryWrapper.create())); + System.out.println(allAccounts); //count 5 + + + //分页查询,第 2 页,每页 3 条数据 + Page accountPage = bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.paginate(2, 3, QueryWrapper.create())); + System.out.println(accountPage); + + + Account optionsAccount = new Account(); + optionsAccount.setUserName("optionstest"); + optionsAccount.addOption("c1", 11); + optionsAccount.addOption("c2", "zhang"); + optionsAccount.addOption("c3", new Date()); + + + bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.insert(optionsAccount)); + System.out.println(">>>>>>> optionsAccount: " + optionsAccount.getId()); + + + Account selectOptionsAccount = bootstrap.execute(AccountMapper.class, accountMapper -> + accountMapper.selectOneById(optionsAccount.getId())); + System.out.println(selectOptionsAccount); } }