Browse Source

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

= 7 years ago
parent
commit
6277799612

+ 15 - 0
mybatis-plus-generator/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;
+
     /**
      * 数据库表映射到实体的命名策略
      */
@@ -176,6 +181,16 @@ public class StrategyConfig {
         return isCapitalMode && StringUtils.isCapitalMode(word);
     }
 
+
+    public boolean isSkipView() {
+        return skipView;
+    }
+
+    public StrategyConfig setSkipView(boolean skipView) {
+        this.skipView = skipView;
+        return this;
+    }
+
     /**
      * <p>
      * 表名称包含指定前缀

+ 4 - 0
mybatis-plus-generator/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);