From 4a604c3bf7b5d5bcc080ca7535b4a8a7c2ec014c Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Thu, 22 Jun 2023 12:35:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E4=BB=A3=E6=9B=BF?= =?UTF-8?q?=E5=8C=85=E8=A3=85=E7=B1=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mybatisflex/codegen/entity/Column.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java index 4a3feef3..af87d4d8 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java @@ -57,7 +57,7 @@ public class Column { /** * 是否自增。 */ - private Boolean isAutoIncrement; + private boolean isAutoIncrement; /** * 是否需要生成 @Column 注解。 From ebfdae3d14ff695a6221662df2d742142c4df6a4 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Thu, 22 Jun 2023 13:02:27 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E7=AD=96=E7=95=A5=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=20schema=20=E5=92=8C=20tableConfig=20=E4=B8=AD=E7=9A=84=20sche?= =?UTF-8?q?ma=20=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BB=A5=20t?= =?UTF-8?q?ableConfig=20=E4=B8=AD=E9=85=8D=E7=BD=AE=E7=9A=84=20schema=20?= =?UTF-8?q?=E4=B8=BA=E4=B8=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mybatisflex/codegen/entity/Table.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java index c0e96cc0..3a21c971 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java @@ -203,14 +203,27 @@ public class Table { tableAnnotation.append("@Table(value = \"").append(name).append("\""); - if (StringUtil.isNotBlank(schema)) { - tableAnnotation.append(", schema = \"").append(schema).append("\""); + String globalSchema; + + if (tableConfig == null) { + // 未配置 tableConfig 以策略中的 schema 为主 + globalSchema = schema; + } else if (StringUtil.isBlank(tableConfig.getSchema())) { + // 配置 tableConfig 但未指定 schema 还是以策略中的 schema 为主 + globalSchema = schema; + } else { + // 以用户设置的 tableConfig 中的 schema 为主 + globalSchema = null; + } + + if (StringUtil.isNotBlank(globalSchema)) { + tableAnnotation.append(", schema = \"").append(globalSchema).append("\""); } if (tableConfig != null) { -// if (tableConfig.getSchema() != null) { -// tableAnnotation.append(", schema = \"").append(tableConfig.getSchema()).append("\""); -// } + if (StringUtil.isNotBlank(tableConfig.getSchema())) { + tableAnnotation.append(", schema = \"").append(tableConfig.getSchema()).append("\""); + } if (tableConfig.getCamelToUnderline() != null) { tableAnnotation.append(", camelToUnderline = \"").append(tableConfig.getCamelToUnderline()).append("\""); } From 36be457be2805815911fe4e4c2a2e09d75fe68e3 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Thu, 22 Jun 2023 13:04:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?style:=20=E5=8F=96=E6=B6=88=20append=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E9=87=8C=E9=9D=A2=E4=BD=BF=E7=94=A8=E5=8A=A0?= =?UTF-8?q?=E5=8F=B7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatisflex/codegen/entity/Column.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java index af87d4d8..fee791eb 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java @@ -139,10 +139,9 @@ public class Column { if (StringUtil.isBlank(comment)) { return ""; } else { - StringBuilder sb = new StringBuilder("/**\n") - .append(" * ").append(comment).append("\n") - .append(" */"); - return sb.toString(); + return "/**\n" + + " * " + comment + "\n" + + " */"; } } @@ -163,19 +162,19 @@ public class Column { annotations.append("keyType = KeyType.Auto"); needComma = true; } else if (columnConfig.getKeyType() != null) { - annotations.append("keyType = KeyType." + columnConfig.getKeyType().name()); + annotations.append("keyType = KeyType.").append(columnConfig.getKeyType().name()); needComma = true; } if (columnConfig.getKeyValue() != null) { addComma(annotations, needComma); - annotations.append("value = \"" + columnConfig.getKeyValue() + "\""); + annotations.append("value = \"").append(columnConfig.getKeyValue()).append("\""); needComma = true; } if (columnConfig.getKeyBefore() != null) { addComma(annotations, needComma); - annotations.append("before = " + columnConfig.getKeyBefore()); + annotations.append("before = ").append(columnConfig.getKeyBefore()); } if (annotations.length() == 4) { @@ -199,43 +198,43 @@ public class Column { annotations.append("@Column("); boolean needComma = false; if (needGenColumnAnnotation) { - annotations.append("value = \"" + name + "\""); + annotations.append("value = \"").append(name).append("\""); needComma = true; } if (columnConfig.getOnInsertValue() != null) { addComma(annotations, needComma); - annotations.append("onInsertValue = \"" + columnConfig.getOnInsertValue() + "\""); + annotations.append("onInsertValue = \"").append(columnConfig.getOnInsertValue()).append("\""); needComma = true; } if (columnConfig.getOnUpdateValue() != null) { addComma(annotations, needComma); - annotations.append("onUpdateValue = \"" + columnConfig.getOnUpdateValue() + "\""); + annotations.append("onUpdateValue = \"").append(columnConfig.getOnUpdateValue()).append("\""); needComma = true; } if (columnConfig.getLarge() != null) { addComma(annotations, needComma); - annotations.append("isLarge = " + columnConfig.getLarge()); + annotations.append("isLarge = ").append(columnConfig.getLarge()); needComma = true; } if (columnConfig.getLogicDelete() != null) { addComma(annotations, needComma); - annotations.append("isLogicDelete = " + columnConfig.getLogicDelete()); + annotations.append("isLogicDelete = ").append(columnConfig.getLogicDelete()); needComma = true; } if (columnConfig.getVersion() != null) { addComma(annotations, needComma); - annotations.append("version = " + columnConfig.getVersion()); + annotations.append("version = ").append(columnConfig.getVersion()); needComma = true; } if (columnConfig.getJdbcType() != null) { addComma(annotations, needComma); - annotations.append("jdbcType = JdbcType." + columnConfig.getJdbcType().name()); + annotations.append("jdbcType = JdbcType.").append(columnConfig.getJdbcType().name()); needComma = true; } if (columnConfig.getTypeHandler() != null) { addComma(annotations, needComma); - annotations.append("typeHandler = " + columnConfig.getTypeHandler().getSimpleName() + ".class"); + annotations.append("typeHandler = ").append(columnConfig.getTypeHandler().getSimpleName()).append(".class"); needComma = true; } if (Boolean.TRUE.equals(columnConfig.getTenantId())) { @@ -247,7 +246,7 @@ public class Column { //@ColumnMask 注解 if (columnConfig.getMask() != null) { - annotations.append("@ColumnMask(\"" + columnConfig.getMask() + "\")"); + annotations.append("@ColumnMask(\"").append(columnConfig.getMask()).append("\")"); } String result = annotations.toString(); From b693bdfb337889311abb1c778a9848836f4709e3 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Thu, 22 Jun 2023 13:31:39 +0800 Subject: [PATCH 4/5] =?UTF-8?q?style:=20=E5=88=A0=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AF=BC=E5=85=A5=E5=8C=85=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mybatisflex/codegen/config/GlobalConfig.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 fbd1d848..84830176 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 @@ -16,7 +16,6 @@ package com.mybatisflex.codegen.config; import com.mybatisflex.codegen.template.ITemplate; -import com.mybatisflex.core.util.StringUtil; import java.util.HashMap; import java.util.Map; @@ -501,7 +500,7 @@ public class GlobalConfig { } /** - * @see StrategyConfig#setTablePrefix(String) + * @see StrategyConfig#setTablePrefix(String...) */ public void setTablePrefix(String... tablePrefix) { getStrategyConfig().setTablePrefix(tablePrefix); From d1bf1acdd59417d8abb470760af1ced15abd4751 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Thu, 22 Jun 2023 13:38:00 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E5=B0=86=E8=BE=85=E5=8A=A9=E7=B1=BB?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E9=BB=98=E8=AE=A4=E5=90=8E=E7=BC=80?= =?UTF-8?q?=E7=94=B1=20Def=20=E6=94=B9=E4=B8=BA=20TableDef=20=E4=B8=8E=20A?= =?UTF-8?q?PT=20=E7=94=9F=E6=88=90=E7=9A=84=E7=B1=BB=E5=90=8D=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=B8=80=E8=87=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/codegen/config/TableDefConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java index f909ac11..3cd594e2 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java @@ -32,7 +32,7 @@ public class TableDefConfig { /** * TableDef 类的后缀。 */ - private String classSuffix = "Def"; + private String classSuffix = "TableDef"; /** * 是否覆盖之前生成的文件。