Explorar el Código

增加虚谷数据库代码生成支持.

https://github.com/baomidou/generator/issues/2
lanjerry hace 4 años
padre
commit
0104811aed

+ 17 - 16
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/DataSourceConfig.java

@@ -47,7 +47,7 @@ public class DataSourceConfig {
      */
     private DbType dbType;
     /**
-     * PostgreSQL schemaName
+     * schemaName
      */
     private String schemaName;
     /**
@@ -114,34 +114,35 @@ public class DataSourceConfig {
      * @return 类型枚举值,如果没找到,则返回 null
      */
     private DbType getDbType(String str) {
-        if (str.contains("mysql")) {
+        if (str.contains(":mysql:") || str.contains(":cobar:")) {
             return DbType.MYSQL;
-        } else if (str.contains("oracle")) {
+        } else if (str.contains(":oracle:")) {
             return DbType.ORACLE;
-        } else if (str.contains("postgresql")) {
+        } else if (str.contains(":postgresql:")) {
             return DbType.POSTGRE_SQL;
-        } else if (str.contains("sqlserver")) {
+        } else if (str.contains(":sqlserver:")) {
             return DbType.SQL_SERVER;
-        } else if (str.contains("db2")) {
+        } else if (str.contains(":db2:")) {
             return DbType.DB2;
-        } else if (str.contains("mariadb")) {
+        } else if (str.contains(":mariadb:")) {
             return DbType.MARIADB;
-        } else if (str.contains("sqlite")) {
+        } else if (str.contains(":sqlite:")) {
             return DbType.SQLITE;
-        } else if (str.contains("h2")) {
+        } else if (str.contains(":h2:")) {
             return DbType.H2;
-        } else if (str.contains("kingbase") || str.contains("kingbase8")) {
+        } else if (str.contains(":kingbase:") || str.contains(":kingbase8:")) {
             return DbType.KINGBASE_ES;
-        } else if (str.contains("dm")) {
+        } else if (str.contains(":dm:")) {
             return DbType.DM;
-        } else if (str.contains("zenith")) {
+        } else if (str.contains(":zenith:")) {
             return DbType.GAUSS;
-        } else if (str.contains("oscar")) {
+        } else if (str.contains(":oscar:")) {
             return DbType.OSCAR;
-        } else if (str.contains("firebird")) {
+        } else if (str.contains(":firebird:")) {
             return DbType.FIREBIRD;
-        }
-        else {
+        } else if (str.contains(":xugu:")) {
+            return DbType.XU_GU;
+        } else {
             return DbType.OTHER;
         }
     }

+ 4 - 3
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/querys/DbQueryRegistry.java

@@ -15,12 +15,12 @@
  */
 package com.baomidou.mybatisplus.generator.config.querys;
 
-import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.generator.config.IDbQuery;
-
 import java.util.EnumMap;
 import java.util.Map;
 
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.generator.config.IDbQuery;
+
 /**
  * @author nieqiuqiu
  * @date 2020-01-09
@@ -44,6 +44,7 @@ public class DbQueryRegistry {
         db_query_enum_map.put(DbType.GAUSS, new GaussQuery());
         db_query_enum_map.put(DbType.OSCAR, new OscarQuery());
         db_query_enum_map.put(DbType.FIREBIRD, new FirebirdQuery());
+        db_query_enum_map.put(DbType.XU_GU, new XuguQuery());
     }
 
     public IDbQuery getDbQuery(DbType dbType) {

+ 67 - 0
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/querys/XuguQuery.java

@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.baomidou.mybatisplus.generator.config.querys;
+
+/**
+ * <p>
+ * Xugu 表数据查询
+ * </p>
+ *
+ * @author unique1319 lanjerry
+ * @since 2020-10-26
+ */
+public class XuguQuery extends AbstractDbQuery {
+
+    @Override
+    public String tablesSql() {
+        return "SELECT * FROM ALL_TABLES WHERE 1 = 1";
+    }
+
+    @Override
+    public String tableFieldsSql() {
+        return "SELECT B.COL_NAME,B.TYPE_NAME,B.COMMENTS, '' AS KEY FROM ALL_TABLES A INNER JOIN ALL_COLUMNS B ON A.TABLE_ID = B.TABLE_ID WHERE A.TABLE_NAME = '%s'";
+    }
+
+    @Override
+    public String tableName() {
+        return "TABLE_NAME";
+    }
+
+    @Override
+    public String tableComment() {
+        return "COMMENTS";
+    }
+
+    @Override
+    public String fieldName() {
+        return "COL_NAME";
+    }
+
+    @Override
+    public String fieldType() {
+        return "TYPE_NAME";
+    }
+
+    @Override
+    public String fieldComment() {
+        return "COMMENTS";
+    }
+
+    @Override
+    public String fieldKey() {
+        return "KEY";
+    }
+}