Commit 25ebaacd authored by 李秀明's avatar 李秀明

Merge remote-tracking branch 'origin/develop_dl_bugfix' into develop_dl_bugfix

parents 0ec7035d 7474492a
...@@ -24,12 +24,13 @@ import java.util.Properties; ...@@ -24,12 +24,13 @@ import java.util.Properties;
@Intercepts({ @Intercepts({
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
} }
) )
public class PluginInterceptor implements Interceptor { public class PluginInterceptor implements Interceptor {
/** /**
* 进行拦截的时候要执行的方法 * 进行拦截的时候要执行的方法
*
* @param invocation * @param invocation
* @return * @return
* @throws Throwable * @throws Throwable
...@@ -56,25 +57,25 @@ public class PluginInterceptor implements Interceptor { ...@@ -56,25 +57,25 @@ public class PluginInterceptor implements Interceptor {
cacheKey = (CacheKey) args[4]; cacheKey = (CacheKey) args[4];
boundSql = (BoundSql) args[5]; boundSql = (BoundSql) args[5];
} }
//id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser //id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser
String id = mappedStatement.getId(); String id = mappedStatement.getId();
//获取到原始sql语句 //获取到原始sql语句
String sql = boundSql.getSql(); String sql = boundSql.getSql();
if("com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonListCount".equals(id) || if ("com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonListCount".equals(id) ||
"com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonList".equals(id)) { "com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonList".equals(id)) {
HashMap par = new HashMap(); HashMap par = new HashMap();
if(parameter instanceof HashMap) { if (parameter instanceof HashMap) {
par = (HashMap)((HashMap<?, ?>) parameter).get("map"); par = (HashMap) ((HashMap<?, ?>) parameter).get("map");
} }
LinkedHashMap<String,String> fieldsValue = (LinkedHashMap<String, String>) par.get("fieldsValue"); LinkedHashMap<String, String> fieldsValue = (LinkedHashMap<String, String>) par.get("fieldsValue");
Iterator<String> iterator = fieldsValue.keySet().stream().iterator(); Iterator<String> iterator = fieldsValue.keySet().stream().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String next = iterator.next(); String next = iterator.next();
sql = sql.replaceFirst("item",next).replaceFirst("ietmValue", new StringBuffer().append("'").append(fieldsValue.get(next)).append("'").toString()); sql = sql.replaceFirst("item", next).replaceFirst("ietmValue", new StringBuffer().append("'").append(fieldsValue.get(next)).append("'").toString());
} }
//通过反射修改sql语句 //通过反射修改sql语句
...@@ -82,7 +83,7 @@ public class PluginInterceptor implements Interceptor { ...@@ -82,7 +83,7 @@ public class PluginInterceptor implements Interceptor {
field.setAccessible(true); field.setAccessible(true);
field.set(boundSql, sql); field.set(boundSql, sql);
return executor.query(mappedStatement, parameter, rowBounds, resultHandler, cacheKey, boundSql); return executor.query(mappedStatement, parameter, rowBounds, resultHandler, cacheKey, boundSql);
} else { } else {
return invocation.proceed(); return invocation.proceed();
} }
} }
......
...@@ -22,12 +22,13 @@ import java.util.Properties; ...@@ -22,12 +22,13 @@ import java.util.Properties;
@Intercepts({ @Intercepts({
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
} }
) )
public class PluginInterceptor implements Interceptor { public class PluginInterceptor implements Interceptor {
/** /**
* 进行拦截的时候要执行的方法 * 进行拦截的时候要执行的方法
*
* @param invocation * @param invocation
* @return * @return
* @throws Throwable * @throws Throwable
...@@ -54,17 +55,17 @@ public class PluginInterceptor implements Interceptor { ...@@ -54,17 +55,17 @@ public class PluginInterceptor implements Interceptor {
cacheKey = (CacheKey) args[4]; cacheKey = (CacheKey) args[4];
boundSql = (BoundSql) args[5]; boundSql = (BoundSql) args[5];
} }
//id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser //id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser
String id = mappedStatement.getId(); String id = mappedStatement.getId();
//获取到原始sql语句 //获取到原始sql语句
String sql = boundSql.getSql(); String sql = boundSql.getSql();
if("com.yeejoin.equipmanage.mapper.FormInstanceMapper.queryForMapList".equals(id)) { if ("com.yeejoin.equipmanage.mapper.FormInstanceMapper.queryForMapList".equals(id)) {
//执行结果 //执行结果
HashMap<String,String> par = new LinkedHashMap<>(); HashMap<String, String> par = new LinkedHashMap<>();
if(parameter instanceof HashMap) { if (parameter instanceof HashMap) {
par = (HashMap<String, String>)((HashMap<?, ?>) parameter).get("params"); par = (HashMap<String, String>) ((HashMap<?, ?>) parameter).get("params");
} }
...@@ -72,7 +73,7 @@ public class PluginInterceptor implements Interceptor { ...@@ -72,7 +73,7 @@ public class PluginInterceptor implements Interceptor {
while (iterator.hasNext()) { while (iterator.hasNext()) {
String next = iterator.next(); String next = iterator.next();
sql = sql.replace("item",next); sql = sql.replace("item", next);
} }
//通过反射修改sql语句 //通过反射修改sql语句
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment