|
@@ -34,7 +34,7 @@ public class SqlInterceptor implements Interceptor {
|
|
|
* //System.out.println(name);
|
|
|
*/
|
|
|
String sql = statementHandler.getBoundSql().getSql();
|
|
|
- if(sql.contains("{DBNAME}.")){
|
|
|
+ if (sql.contains("{DBNAME}.")) {
|
|
|
String modifiedSql = modifySql(sql);
|
|
|
if (modifiedSql.equals("error")) {
|
|
|
return AjaxResult.error("当前用户没有数据源信息!");
|
|
@@ -42,7 +42,13 @@ public class SqlInterceptor implements Interceptor {
|
|
|
ReflectUtils.setFieldValue(statementHandler.getBoundSql(), "sql", modifiedSql);
|
|
|
return invocation.proceed();
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
+ // 达梦数据源下 ``不识别
|
|
|
+ if (sql.contains("m.`query`")) {
|
|
|
+ String endsql = sql.replace("m.`query`", "m.query");
|
|
|
+ ReflectUtils.setFieldValue(statementHandler.getBoundSql(), "sql", endsql);
|
|
|
+ return invocation.proceed();
|
|
|
+ }
|
|
|
// 如果不在指定路径下,直接放行
|
|
|
return invocation.proceed();
|
|
|
}
|
|
@@ -57,8 +63,19 @@ public class SqlInterceptor implements Interceptor {
|
|
|
}
|
|
|
if (SecurityUtils.getDatabaseType().equals("sqlserver"))
|
|
|
return "USE `" + SecurityUtils.getDatabaseName() + "`; " + sql;
|
|
|
- if (SecurityUtils.getDatabaseType().equals("dm"))
|
|
|
+ if (SecurityUtils.getDatabaseType().equals("dm")) {
|
|
|
+ String endSQl;
|
|
|
+ if (sql.contains("{DBNAME}.")) {
|
|
|
+
|
|
|
+ // 如果sql中出现 ` 符号
|
|
|
+// if (sql.contains("`")) {
|
|
|
+// sql.replace("`", "");
|
|
|
+// }
|
|
|
+ return sql.replace("{DBNAME}", SecurityUtils.getDatabaseName()).replace("`", "");
|
|
|
+ }
|
|
|
return "set schema " + SecurityUtils.getDatabaseName() + "; " + sql;
|
|
|
+ }
|
|
|
+
|
|
|
if (SecurityUtils.getDatabaseType().equals("mysql")) {
|
|
|
if (sql.contains("{DBNAME}.")) {
|
|
|
return sql.replace("{DBNAME}.", "`" + SecurityUtils.getDatabaseName() + "`.");
|
|
@@ -112,4 +129,14 @@ public class SqlInterceptor implements Interceptor {
|
|
|
@Override
|
|
|
public void setProperties(Properties properties) {
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+/*
|
|
|
+
|
|
|
+关系对应
|
|
|
+name:code
|
|
|
+age:asd
|
|
|
+state:staue
|
|
|
+默认值:
|
|
|
+state:1
|
|
|
+
|
|
|
+ */
|