From ea5836ab51526e77860e7af4c0cab285d69bd024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= Date: Wed, 12 Feb 2025 16:40:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Codegen=20GlobalCon?= =?UTF-8?q?fig=20=E7=B1=BB=E7=BC=BA=E5=B0=91=20setEntityWithBaseClassEnabl?= =?UTF-8?q?e=20=E5=87=BD=E6=95=B0=E9=97=AE=E9=A2=98=20globalConfig.getEnti?= =?UTF-8?q?tyConfig().setWithBaseClassEnable(true);?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh/others/codegen.md | 1 + .../mybatisflex/codegen/config/GlobalConfig.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/zh/others/codegen.md b/docs/zh/others/codegen.md index 5fb83ea9..93cd2cd4 100644 --- a/docs/zh/others/codegen.md +++ b/docs/zh/others/codegen.md @@ -297,6 +297,7 @@ globalConfig.getTemplateConfig() | 配置 | 描述 | 默认值 | |----------------------------------------------|---------------------------------------------------|--------------------| +| setEntityWithBaseClassEnable(boolean) | 当开启这个配置后,Entity 会生成两个类,自动生成的 getter setter 字段等都在 Base 类里,而开发者可以在 Account.java 中添加自己的业务代码 | false | | setClassPrefix(String) | Entity 类的前缀 | "" | | setClassSuffix(String) | Entity 类的后缀 | "" | | setSuperClass(Class) | Entity 类的父类,可以自定义一些 BaseEntity 类 | null | diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java index 1c99efbb..dfc533d1 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java @@ -1035,6 +1035,20 @@ public class GlobalConfig implements Serializable { getEntityConfig().setJdkVersion(jdkVersion); } + /** + * @see EntityConfig#isWithBaseClassEnable() + */ + public boolean isEntityWithBaseClassEnable() { + return getEntityConfig().isWithBaseClassEnable(); + } + + /** + * @see EntityConfig#setWithBaseClassEnable(boolean) + */ + public void setEntityWithBaseClassEnable(boolean withBaseClassEnable) { + getEntityConfig().setWithBaseClassEnable(withBaseClassEnable); + } + public boolean isMapperGenerateEnable() { return mapperGenerateEnable; }