Browse Source

Merge pull request #4433 from huyang19881115/3.0

添加对 行云 数据库分页的支持
miemieYaho 3 years ago
parent
commit
67758d5102

+ 4 - 0
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/DbType.java

@@ -164,6 +164,10 @@ public enum DbType {
      * Vertica
      */
     VERTICA("vertica", "vertica数据库"),
+    /**
+     * xcloud
+     */
+    XCloud("xcloud", "行云数据库"),
     /**
      * UNKONWN DB
      */

+ 8 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/DialectFactory.java

@@ -80,6 +80,14 @@ public class DialectFactory {
                 dialect = new SQLServer2005Dialect();
             } else if (dbType == DbType.SYBASE) {
                 dialect = new SybaseDialect();
+            } else if (dbType == DbType.GBASEDBT) {
+                dialect = new GBasedbtDialect();
+            } else if (dbType == DbType.GBASE_INFORMIX) {
+                dialect = new GBaseInfromixDialect();
+            }else if (dbType == DbType.XCloud){
+                dialect = new XCloudDialect();
+            } else if (dbType == DbType.FIREBIRD) {
+                dialect = new FirebirdDialect();
             } else if (dbType == DbType.GBASE_8S
                 || dbType == DbType.GBASEDBT
                 || dbType == DbType.GBASE_INFORMIX) {

+ 46 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/dialects/XCloudDialect.java

@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ *
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.extension.plugins.pagination.dialects;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.DialectModel;
+
+/**
+ * XCloud 数据库分页语句组装实现
+ *
+ * @author huyang
+ * @since 2022-04-13
+ */
+public class XCloudDialect implements IDialect {
+    /**
+     *
+     * @param originalSql
+     * @param offset
+     * @param limit
+     * @return
+     */
+
+    @Override
+    public DialectModel buildPaginationSql(String originalSql, long offset, long limit) {
+        StringBuilder sql = new StringBuilder(originalSql).append(" LIMIT ");
+        if (offset != 0L) {
+            sql.append(" ("+FIRST_MARK +","+SECOND_MARK+") ") ;
+            return new DialectModel(sql.toString(), offset+1, offset+limit).setConsumerChain();
+        } else {
+            sql.append(FIRST_MARK);
+            return new DialectModel(sql.toString(), limit).setConsumer(true);
+        }
+    }
+}

+ 3 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/toolkit/JdbcUtils.java

@@ -120,6 +120,9 @@ public class JdbcUtils {
             return DbType.IMPALA;
         } else if (url.contains(":vertica:")) {
             return DbType.VERTICA;
+        } else if (url.contains(":xcloud:")) {
+            return DbType.XCloud;
+        }else {
         } else if (url.contains(":firebirdsql:")) {
             return DbType.FIREBIRD;
         } else {