Przeglądaj źródła

fixed github issues/236 可配置视图跳过

= 7 lat temu
rodzic
commit
366567ea13

+ 15 - 1
mybatis-plus-generate/src/main/java/com/baomidou/mybatisplus/generator/config/StrategyConfig.java

@@ -41,6 +41,11 @@ public class StrategyConfig {
      */
     private boolean isCapitalMode = false;
 
+    /**
+     * 是否跳过视图
+     */
+    private boolean skipView = false;
+
     /**
      * 数据库表映射到实体的命名策略
      */
@@ -91,7 +96,7 @@ public class StrategyConfig {
      */
     private String superControllerClass;
 
-    /*
+    /**
      * 需要包含的表名(与exclude二选一配置)
      */
     private String[] include = null;
@@ -207,6 +212,15 @@ public class StrategyConfig {
         return this;
     }
 
+    public boolean isSkipView() {
+        return skipView;
+    }
+
+    public StrategyConfig setSkipView(boolean skipView) {
+        this.skipView = skipView;
+        return this;
+    }
+
     public NamingStrategy getNaming() {
         return naming;
     }

+ 4 - 0
mybatis-plus-generate/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java

@@ -460,6 +460,10 @@ public class ConfigBuilder {
                 String tableName = results.getString(querySQL.getTableName());
                 if (StringUtils.isNotEmpty(tableName)) {
                     String tableComment = results.getString(querySQL.getTableComment());
+                    if (config.isSkipView() && "VIEW".equals(tableComment)) {
+                        // 跳过视图
+                        continue;
+                    }
                     tableInfo = new TableInfo();
                     tableInfo.setName(tableName);
                     tableInfo.setComment(tableComment);