Browse Source

添加机车kingbase

hexiao 2 years ago
parent
commit
5eae46101d

+ 3 - 1
base-framework/src/main/java/com/ozs/framework/config/CipherMybatisPlusConfig.java

@@ -20,6 +20,8 @@ public class CipherMybatisPlusConfig {
     @Value("${base.sql-type:mysql}")
     private String type;
 
+    @Value("${base.dbname:vehicle}")
+    private String dbname;
 
     @Bean
     public MybatisPlusInterceptor mybatisPlusInterceptor() {
@@ -31,7 +33,7 @@ public class CipherMybatisPlusConfig {
         }
         // 自定义拦截器,先添加先执行。
         if (type.equals(DbType.KINGBASE_ES.getDb())) {
-            interceptor.addInnerInterceptor(new KindBaseSqlMybatisIntercepts());
+            interceptor.addInnerInterceptor(new KindBaseSqlMybatisIntercepts(dbname));
         }
 
         // 自带分页拦截器

+ 8 - 1
base-framework/src/main/java/com/ozs/framework/config/KindBaseSqlMybatisIntercepts.java

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
 import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
 import com.baomidou.mybatisplus.core.toolkit.TableNameParser;
 import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
 import org.apache.ibatis.executor.Executor;
 import org.apache.ibatis.executor.statement.StatementHandler;
 import org.apache.ibatis.mapping.BoundSql;
@@ -17,8 +20,12 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
 public class KindBaseSqlMybatisIntercepts implements InnerInterceptor {
 
+    private String dbname;
 
     // 重写查询方法修改表名
     @Override
@@ -56,7 +63,7 @@ public class KindBaseSqlMybatisIntercepts implements InnerInterceptor {
             int start = name.getStart();
             if (start != last) {
                 builder.append(sql, last, start);
-                builder.append("vehicle.");
+                builder.append(dbname + ".");
                 builder.append(tname);
 //                builder.append("\"");
             }