diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index e7dd1bad..255d157f 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -33,51 +33,51 @@ export default defineConfig({ { text: '简介', items: [ - {text: 'Mybatis-Flex 是什么', link: '/zh/what-is-mybatisflex'}, - {text: '快速开始', link: '/zh/getting-started'}, - {text: 'Maven 依赖', link: '/zh/maven'}, - {text: '和同类框架「功能」对比', link: '/zh/comparison'}, - {text: '和同类框架「性能」对比', link: '/zh/benchmark'}, - {text: '使用 Mybatis 原生功能', link: '/zh/use-mybatis-native'}, - {text: '支持的数据库类型', link: '/zh/support-database'}, - {text: 'QQ 交流群', link: '/zh/qq-group'}, + {text: 'Mybatis-Flex 是什么', link: '/zh/introduction/01-what-is-mybatisflex'}, + {text: '快速开始', link: '/zh/introduction/02-getting-started'}, + {text: 'Maven 依赖', link: '/zh/introduction/03-maven'}, + {text: '和同类框架「功能」对比', link: '/zh/introduction/04-comparison'}, + {text: '和同类框架「性能」对比', link: '/zh/introduction/05-benchmark'}, + {text: '使用 Mybatis 原生功能', link: '/zh/introduction/06-use-mybatis-native'}, + {text: '支持的数据库类型', link: '/zh/introduction/07-support-database'}, + {text: 'QQ 交流群', link: '/zh/introduction/08-qq-group'}, ] }, { text: '基础功能', items: [ - {text: '增删改', link: '/zh/add-delete-update'}, - {text: '查询和分页', link: '/zh/query'}, - {text: 'QueryWrapper', link: '/zh/querywrapper'}, + {text: '增删改', link: '/zh/base/01-add-delete-update'}, + {text: '查询和分页', link: '/zh/base/02-query'}, + {text: 'QueryWrapper', link: '/zh/base/03-querywrapper'}, ] }, { text: '核心功能', items: [ - {text: '@Table 注解', link: '/zh/table'}, - {text: '@Id 注解', link: '/zh/id'}, - {text: '@Column 注解', link: '/zh/column'}, - {text: 'Db + Row', link: '/zh/db-row'}, - {text: '逻辑删除', link: '/zh/logic-delete'}, - {text: '乐观锁', link: '/zh/version'}, - {text: '数据填充', link: '/zh/fill'}, - {text: '数据脱敏', link: '/zh/mask'}, - {text: 'SQL 审计', link: '/zh/audit'}, - {text: 'SQL 打印', link: '/zh/sql-print'}, - {text: '多数据源', link: '/zh/multi-datasource'}, - {text: '事务管理', link: '/zh/tx'}, - {text: '字段权限', link: '/zh/columns-permission'}, - {text: '字段加密', link: '/zh/columns-encrypt'}, - {text: '字典回写', link: '/zh/columns-dict'}, - {text: '枚举属性', link: '/zh/enum-property'}, - {text: '多租户', link: '/zh/multi-tenancy'}, + {text: '@Table 注解', link: '/zh/core/01-table'}, + {text: '@Id 注解', link: '/zh/core/02-id'}, + {text: '@Column 注解', link: '/zh/core/03-column'}, + {text: 'Db + Row', link: '/zh/core/04-db-row'}, + {text: '逻辑删除', link: '/zh/core/05-logic-delete'}, + {text: '乐观锁', link: '/zh/core/06-version'}, + {text: '数据填充', link: '/zh/core/07-fill'}, + {text: '数据脱敏', link: '/zh/core/08-mask'}, + {text: 'SQL 审计', link: '/zh/core/09-audit'}, + {text: 'SQL 打印', link: '/zh/core/10-sql-print'}, + {text: '多数据源', link: '/zh/core/11-multi-datasource'}, + {text: '事务管理', link: '/zh/core/12-tx'}, + {text: '字段权限', link: '/zh/core/13-columns-permission'}, + {text: '字段加密', link: '/zh/core/14-columns-encrypt'}, + {text: '字典回写', link: '/zh/core/15-columns-dict'}, + {text: '枚举属性', link: '/zh/core/16-enum-property'}, + {text: '多租户', link: '/zh/core/17-multi-tenancy'}, ] }, { text: '其他', items: [ - {text: '代码生成器', link: '/zh/codegen'}, - {text: 'APT 设置', link: '/zh/apt'}, + {text: '代码生成器', link: '/zh/others/01-codegen'}, + {text: 'APT 设置', link: '/zh/others/02-apt'}, ] } ], diff --git a/docs/zh/add-delete-update.md b/docs/zh/base/01-add-delete-update.md similarity index 100% rename from docs/zh/add-delete-update.md rename to docs/zh/base/01-add-delete-update.md diff --git a/docs/zh/query.md b/docs/zh/base/02-query.md similarity index 100% rename from docs/zh/query.md rename to docs/zh/base/02-query.md diff --git a/docs/zh/querywrapper.md b/docs/zh/base/03-querywrapper.md similarity index 99% rename from docs/zh/querywrapper.md rename to docs/zh/base/03-querywrapper.md index 8165e269..40a5caa5 100644 --- a/docs/zh/querywrapper.md +++ b/docs/zh/base/03-querywrapper.md @@ -430,7 +430,7 @@ SELECT * FROM "tb_account" ORDER BY "id" DESC ROWS 20 TO 30 会自动根据 Entity 类定义的字段生成 "ACCOUNT" 类以及 Entity 对应的 Mapper 类, 通过开发工具构建项目(如下图), 或者执行 maven 编译命令: `mvn clean package` 都可以自动生成。这个原理和 lombok 一致。 -![](../assets/images/build_idea.png) +![](../../assets/images/build_idea.png) > 更多关于 APT 的配置,请进入 [APT 配置章节](./apt) 了解。 diff --git a/docs/zh/table.md b/docs/zh/core/01-table.md similarity index 100% rename from docs/zh/table.md rename to docs/zh/core/01-table.md diff --git a/docs/zh/id.md b/docs/zh/core/02-id.md similarity index 100% rename from docs/zh/id.md rename to docs/zh/core/02-id.md diff --git a/docs/zh/column.md b/docs/zh/core/03-column.md similarity index 97% rename from docs/zh/column.md rename to docs/zh/core/03-column.md index 52d8bfe7..f70ab469 100644 --- a/docs/zh/column.md +++ b/docs/zh/core/03-column.md @@ -195,11 +195,11 @@ QueryWrapper.create() ## isLogicDelete -这部分的文档参考 [逻辑删除章节](./logic-delete.md)。 +这部分的文档参考 [逻辑删除章节](./05-logic-delete.md)。 ## version -这部分的文档参考 [乐观锁章节](./version.md)。 +这部分的文档参考 [乐观锁章节](./06-version.md)。 ## typeHandler @@ -276,4 +276,4 @@ mybatis-flex 内置的扩展 typeHandler 还有: 在某些场景下,我们的 entity 可能会有通用的字段以及配置,这种场景如果我们要为每个 entity 去设置,这会相对麻烦。 在这种场景下,我们可以建立一个通用的 BaseEntity 类,然后让所有的 Entity 都继承是该类。 -Entity 一般是通过代码生成器生成的,我们通过 `GlobalConfig.entitySupperClass` 可以为代码生成器配置全局的 Entity 父类,更多关于代码生成器可以请访问 [这里](./codegen.md)。 \ No newline at end of file +Entity 一般是通过代码生成器生成的,我们通过 `GlobalConfig.entitySupperClass` 可以为代码生成器配置全局的 Entity 父类,更多关于代码生成器可以请访问 [这里](../others/01-codegen.md)。 \ No newline at end of file diff --git a/docs/zh/db-row.md b/docs/zh/core/04-db-row.md similarity index 100% rename from docs/zh/db-row.md rename to docs/zh/core/04-db-row.md diff --git a/docs/zh/logic-delete.md b/docs/zh/core/05-logic-delete.md similarity index 100% rename from docs/zh/logic-delete.md rename to docs/zh/core/05-logic-delete.md diff --git a/docs/zh/version.md b/docs/zh/core/06-version.md similarity index 100% rename from docs/zh/version.md rename to docs/zh/core/06-version.md diff --git a/docs/zh/fill.md b/docs/zh/core/07-fill.md similarity index 100% rename from docs/zh/fill.md rename to docs/zh/core/07-fill.md diff --git a/docs/zh/mask.md b/docs/zh/core/08-mask.md similarity index 100% rename from docs/zh/mask.md rename to docs/zh/core/08-mask.md diff --git a/docs/zh/audit.md b/docs/zh/core/09-audit.md similarity index 100% rename from docs/zh/audit.md rename to docs/zh/core/09-audit.md diff --git a/docs/zh/sql-print.md b/docs/zh/core/10-sql-print.md similarity index 100% rename from docs/zh/sql-print.md rename to docs/zh/core/10-sql-print.md diff --git a/docs/zh/multi-datasource.md b/docs/zh/core/11-multi-datasource.md similarity index 100% rename from docs/zh/multi-datasource.md rename to docs/zh/core/11-multi-datasource.md diff --git a/docs/zh/tx.md b/docs/zh/core/12-tx.md similarity index 100% rename from docs/zh/tx.md rename to docs/zh/core/12-tx.md diff --git a/docs/zh/columns-permission.md b/docs/zh/core/13-columns-permission.md similarity index 96% rename from docs/zh/columns-permission.md rename to docs/zh/core/13-columns-permission.md index 83263fd6..3a664a03 100644 --- a/docs/zh/columns-permission.md +++ b/docs/zh/core/13-columns-permission.md @@ -48,4 +48,4 @@ public class Account { } ``` -更多的 `onSet` 还可以参考 [这里](./table.md)。 \ No newline at end of file +更多的 `onSet` 还可以参考 [这里](./01-table.md)。 \ No newline at end of file diff --git a/docs/zh/columns-encrypt.md b/docs/zh/core/14-columns-encrypt.md similarity index 93% rename from docs/zh/columns-encrypt.md rename to docs/zh/core/14-columns-encrypt.md index 271a709a..14d1e7ab 100644 --- a/docs/zh/columns-encrypt.md +++ b/docs/zh/core/14-columns-encrypt.md @@ -38,4 +38,4 @@ public class Account { } ``` -更多的 `onSet` 还可以参考 [这里](./table.md)。 \ No newline at end of file +更多的 `onSet` 还可以参考 [这里](./01-table.md)。 \ No newline at end of file diff --git a/docs/zh/columns-dict.md b/docs/zh/core/15-columns-dict.md similarity index 96% rename from docs/zh/columns-dict.md rename to docs/zh/core/15-columns-dict.md index 90bb6f5a..13609ea2 100644 --- a/docs/zh/columns-dict.md +++ b/docs/zh/core/15-columns-dict.md @@ -47,4 +47,4 @@ public class Account { } ``` -更多的 `onSet` 还可以参考 [这里](./table.md)。 \ No newline at end of file +更多的 `onSet` 还可以参考 [这里](./01-table.md)。 \ No newline at end of file diff --git a/docs/zh/enum-property.md b/docs/zh/core/16-enum-property.md similarity index 100% rename from docs/zh/enum-property.md rename to docs/zh/core/16-enum-property.md diff --git a/docs/zh/multi-tenancy.md b/docs/zh/core/17-multi-tenancy.md similarity index 100% rename from docs/zh/multi-tenancy.md rename to docs/zh/core/17-multi-tenancy.md diff --git a/docs/zh/faq.md b/docs/zh/faq.md index 2da364c8..0aa59083 100644 --- a/docs/zh/faq.md +++ b/docs/zh/faq.md @@ -3,7 +3,7 @@ ## 示例中的 AccountMapper 和 "ACCOUNT" 在哪里,报错了。 Mybatis-Flex 使用了 APT 技术,这两个类是自动生成的。 -参考:[Mybatis-Flex APT 配置 - Mybatis-Flex 官方网站](./apt.md) +参考:[Mybatis-Flex APT 配置 - Mybatis-Flex 官方网站](./others/02-apt.md) @@ -76,5 +76,5 @@ spring: 的主动发现机制。若使用 `hikariCP` 数据源,则可以不配置 `type` 内容。 > 若使用多数据源,或者把数据源配置到 `mybatis-flex.datasource` 下,使用 mybatis-flex 的数据源发现机制, -> 使用 druid 也可以不用配置 type,更多文档参考:[多数据源章节](./multi-datasource.md)。 +> 使用 druid 也可以不用配置 type,更多文档参考:[多数据源章节](./core/11-multi-datasource.md)。 diff --git a/docs/zh/what-is-mybatisflex.md b/docs/zh/introduction/01-what-is-mybatisflex.md similarity index 89% rename from docs/zh/what-is-mybatisflex.md rename to docs/zh/introduction/01-what-is-mybatisflex.md index 9f48e63b..d528774a 100644 --- a/docs/zh/what-is-mybatisflex.md +++ b/docs/zh/introduction/01-what-is-mybatisflex.md @@ -23,22 +23,22 @@ QueryWrapper 帮助我们极大的减少了 S ## 一些评价 -![](../assets/images/comments/01.png) +![](../../assets/images/comments/01.png) --- -![](../assets/images/comments/02.png) +![](../../assets/images/comments/02.png) --- -![](../assets/images/comments/03.png) +![](../../assets/images/comments/03.png) --- -![](../assets/images/comments/04.png) +![](../../assets/images/comments/04.png) --- -![](../assets/images/comments/05.png) +![](../../assets/images/comments/05.png) diff --git a/docs/zh/getting-started.md b/docs/zh/introduction/02-getting-started.md similarity index 79% rename from docs/zh/getting-started.md rename to docs/zh/introduction/02-getting-started.md index 1ef1dca0..363b7330 100644 --- a/docs/zh/getting-started.md +++ b/docs/zh/introduction/02-getting-started.md @@ -19,7 +19,9 @@ CREATE TABLE IF NOT EXISTS `tb_account` ); ``` -**第 2 步:创建 java 项目,并添加 Maven 依赖** +**第 2 步:创建 java 项目,并添加 Maven/Gradle 依赖** + +Maven示例: ```xml @@ -29,9 +31,23 @@ CREATE TABLE IF NOT EXISTS `tb_account` ``` +Gradle示例: + +```groovy +// file: build.gradle +ext { + mybatis_flex_version = '1.1.9' +} +dependencies { + implementation("com.mybatis-flex:mybatis-flex-core:${mybatis_flex_version}") + // 启用APT + annotationProcessor("com.mybatis-flex:mybatis-flex-annotation:${mybatis_flex_version}") +} +``` + **第 3 步:编写实体类和 Mapper** -> 这部分可以使用 Mybatis-Flex 的代码生成器来生成实体类哟,功能非常强大的。详情进入:[代码生成器章节](./codegen.md) 了解。 +> 这部分可以使用 Mybatis-Flex 的代码生成器来生成实体类哟,功能非常强大的。详情进入:[代码生成器章节](../others/01-codegen.md) 了解。 ```java @Table("tb_account") @@ -56,9 +72,21 @@ public interface AccountMapper extends BaseMapper { } ``` +**第4步:编译项目自动生成辅助类** + +Mybatis-Flex 使用了 APT(Annotation Processing Tool)技术,在项目编译的时,会自动生成辅助操作类。 + +maven中 `mvn clean package` + +gradle中 `gradlew classes` -**第 4 步:通过 main 方法开始使用(无 Spring 的场景)** + +更多信息请参考:[APT 设置章节](*../others/02-apt.md*) + + + +**第 5 步:通过 main 方法开始使用(无 Spring 的场景)** ```java public class HelloWorld { diff --git a/docs/zh/maven.md b/docs/zh/introduction/03-maven.md similarity index 100% rename from docs/zh/maven.md rename to docs/zh/introduction/03-maven.md diff --git a/docs/zh/comparison.md b/docs/zh/introduction/04-comparison.md similarity index 99% rename from docs/zh/comparison.md rename to docs/zh/introduction/04-comparison.md index a7125c09..f7135ced 100644 --- a/docs/zh/comparison.md +++ b/docs/zh/introduction/04-comparison.md @@ -5,7 +5,7 @@ MyBatis-Flex 主要是和 `MyBatis-Plus` 与 `Fluent-Mybatis` 对比,内容来 - MyBatis-Plus:老牌的 MyBatis 增强框架,开源于 2016 年。 - Fluent-Mybatis:阿里云开发的 Mybatis 增强框架(来至于阿里云·云效产品团队) -> 本文只阐述了「功能」方面的对比,**「性能」** 对比请参考 [这里](./benchmark.md)。 +> 本文只阐述了「功能」方面的对比,**「性能」** 对比请参考 [这里](./05-benchmark.md)。 > 若发现对比中有错误,请加入 Mybatis-Flex QQ 交流群:532992631,然后联系群主纠正。 ## 功能对比 diff --git a/docs/zh/benchmark.md b/docs/zh/introduction/05-benchmark.md similarity index 99% rename from docs/zh/benchmark.md rename to docs/zh/introduction/05-benchmark.md index 1eab062a..e28feda1 100644 --- a/docs/zh/benchmark.md +++ b/docs/zh/introduction/05-benchmark.md @@ -3,7 +3,7 @@ 本文主要是展示了 Mybatis-Flex 和 Mybaits-Plus 的「性能」对比。Mybaits-Plus 是一个非常优秀 Mybaits 增强框架, 其开源于 2016 年,有很多的成功案例。 -本文只阐述了「性能」方面的对比,「功能」对比请参考 [这里](./comparison.md)。 +本文只阐述了「性能」方面的对比,「功能」对比请参考 [这里](./04-comparison.md)。 ## 测试方法 使用 h2 数据库,在初始化的时候分别为 mybatis-flex 和 mybatis-plus 创建两个不同的数据库, 但是完全一样的数据结构、数据内容和数据量(每个库 2w 条数据)。 diff --git a/docs/zh/use-mybatis-native.md b/docs/zh/introduction/06-use-mybatis-native.md similarity index 100% rename from docs/zh/use-mybatis-native.md rename to docs/zh/introduction/06-use-mybatis-native.md diff --git a/docs/zh/support-database.md b/docs/zh/introduction/07-support-database.md similarity index 100% rename from docs/zh/support-database.md rename to docs/zh/introduction/07-support-database.md diff --git a/docs/zh/qq-group.md b/docs/zh/introduction/08-qq-group.md similarity index 57% rename from docs/zh/qq-group.md rename to docs/zh/introduction/08-qq-group.md index 7e861728..5766ff68 100644 --- a/docs/zh/qq-group.md +++ b/docs/zh/introduction/08-qq-group.md @@ -2,4 +2,4 @@ 群号: 532992631 -![](../assets/images/qq_group.png) \ No newline at end of file +![](../../assets/images/qq_group.png) \ No newline at end of file diff --git a/docs/zh/codegen.md b/docs/zh/others/01-codegen.md similarity index 99% rename from docs/zh/codegen.md rename to docs/zh/others/01-codegen.md index cb069167..33891458 100644 --- a/docs/zh/codegen.md +++ b/docs/zh/others/01-codegen.md @@ -82,7 +82,7 @@ public class Codegen { 注意:由于 MyBatis-Flex 的 APT 功能会自动帮我们生成了 Mapper 的 Java 类,如果我们在代码生成器中选择生成 Mapper, 则建议把 APT 的 Mapper 生成功能给关闭掉,否则系统中会存在两份一样功能的 Mapper。 -关闭 APT 的 Mapper 类文件生成,请参考:[APT 设置章节](./apt.md) +关闭 APT 的 Mapper 类文件生成,请参考:[APT 设置章节](../others/02-apt.md) ## 全局配置 GlobalConfig diff --git a/docs/zh/apt.md b/docs/zh/others/02-apt.md similarity index 98% rename from docs/zh/apt.md rename to docs/zh/others/02-apt.md index c4d08c41..12286f19 100644 --- a/docs/zh/apt.md +++ b/docs/zh/others/02-apt.md @@ -3,7 +3,7 @@ Mybatis-Flex 使用了 APT(Annotation Processing Tool)技术,在项目编译的时候,会自动根据 Entity 类定义的字段帮你生成 "ACCOUNT" 类以及 Entity 对应的 Mapper 类, 通过开发工具构建项目(如下图),或者执行 maven 编译命令: `mvn clean package` 都可以自动生成。这个原理和 lombok 一致。 -![](../assets/images/build_idea.png) +![](../../assets/images/build_idea.png) @@ -134,6 +134,6 @@ dependencies { - 1、 先点击 `Generate Sources and Update Folders`。 - 2、 再点击 `Reload project`。 -![](../assets/images/apt_idea.png) +![](../../assets/images/apt_idea.png) diff --git a/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/Column.java b/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/Column.java index 3c17a173..441301fe 100644 --- a/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/Column.java +++ b/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/Column.java @@ -21,6 +21,11 @@ import org.apache.ibatis.type.UnknownTypeHandler; import java.lang.annotation.*; +/** + * 数据库表中的列信息注解 + * + * @author 开源海哥 + */ @Inherited @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) @@ -47,7 +52,7 @@ public @interface Column { String onUpdateValue() default ""; /** - * 是否是大字段,大字段 APT 不会生成到 ALL_COLUMNS 里 + * 是否是大字段,大字段 APT 不会生成到 DEFAULT_COLUMNS 里 */ boolean isLarge() default false; diff --git a/readme_zh.md b/readme_zh.md index 9af8011c..fff0a6bb 100644 --- a/readme_zh.md +++ b/readme_zh.md @@ -390,7 +390,7 @@ QueryWrapper queryWrapper = QueryWrapper.create() ![](./docs/assets/images/build_idea.png) -> 更多关于 Mybatis-Flex APT 的配置,请点击 [这里](./docs/zh/apt.md)。 +> 更多关于 Mybatis-Flex APT 的配置,请点击 [这里](./docs/zh/others/02-apt.md)。 ## Db + Row 工具类 @@ -431,7 +431,7 @@ Page rowPage=Db.paginate("tb_account",3,10,query); > > 具体参考: [Db.java](./mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Db.java) 。 > -> 更多关于 Row 插入时的**主键生成机制**、以及Db 的**事务管理**等,请点击 [这里](./docs/zh/db_row.md) 。 +> 更多关于 Row 插入时的**主键生成机制**、以及Db 的**事务管理**等,请点击 [这里](./docs/zh/core/04-db-row.md) 。 ## Entity 部分字段更新 @@ -575,7 +575,7 @@ public class Account { } ``` -> 更多关于主键的配置,请点击 [这里](./docs/zh/id.md) +> 更多关于主键的配置,请点击 [这里](./docs/zh/core/02-id.md) ## 更多文档