From 90b04302b1f328f40e1375a528a1cbab28eb24e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=BA=90=E6=B5=B7=E5=93=A5?= Date: Mon, 17 Apr 2023 17:06:31 +0800 Subject: [PATCH] update docs --- docs/zh/apt.md | 14 ++++++++++++++ docs/zh/table.md | 15 ++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/zh/apt.md b/docs/zh/apt.md index 1c8292bd..455697c6 100644 --- a/docs/zh/apt.md +++ b/docs/zh/apt.md @@ -53,12 +53,26 @@ processor.tablesClassName = your-class-name processor.mappersPackage = com.your-package ``` +## 自定义 Mapper 的父类 + +默认情况下,生成的所有 Mapper 是都继承 `com.mybatisflex.core.BaseMapper` 接口,但是在某些场景下(比如:新增更多的通用方法等),用户可以自定义自己的 +`BaseMapper`,然后通过 APT 配置生成。 + +```properties +processor.baseMapperClass=com.domain.mapper.MyBaseMapper +``` + + ## APT 关闭 Mapper 生成 +在某些情况下,我们可能需要手写 Mapper,不需要 APT 生成,可以通过如下配置关闭 APT 的生成功能。 + ```properties processor.mappersGenerateEnable = false ``` +以上的配置,会关闭整个项目的 APT 生成,若我们只想关闭某一个 Entity 的 APT 生成,那么可以通过配置注解 `@Table(mapperGenerateEnable = false)` 进行关闭。 + ## 开发工具无法导入生成的代码? 如下图所示,点击项目目录(注意是项目的根目录),右键 > Maven: diff --git a/docs/zh/table.md b/docs/zh/table.md index 53fb0435..edadc087 100644 --- a/docs/zh/table.md +++ b/docs/zh/table.md @@ -19,16 +19,16 @@ public @interface Table { */ String schema() default ""; - /** - * 默认使用哪个数据源,若系统找不到该指定的数据源时,默认使用第一个数据源 - */ - String dataSource() default ""; - /** * 默认为 驼峰属性 转换为 下划线字段 */ boolean camelToUnderline() default true; + /** + * 默认使用哪个数据源,若系统找不到该指定的数据源时,默认使用第一个数据源 + */ + String dataSource() default ""; + /** * 监听 entity 的 insert 行为 */ @@ -43,6 +43,11 @@ public @interface Table { * 监听 entity 的查询数据的 set 行为,用户主动 set 不会触发 */ Class onSet() default NoneListener.class; + + /** + * 在某些场景下,我们需要手动编写 Mapper,可以通过这个注解来关闭 APT 的 Mapper 生成 + */ + boolean mapperGenerateEnable() default true; } ```