Commit 5d926745 authored by chenzhao's avatar chenzhao

修改代码 排除条件中空元素

parent 57558339
......@@ -9,6 +9,7 @@ import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.Select;
import org.apache.commons.lang.ArrayUtils;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql;
......@@ -25,10 +26,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.*;
@Intercepts({@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class,
RowBounds.class, ResultHandler.class}), @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
......@@ -140,19 +138,20 @@ public class UserEmpowerInterceptor implements Interceptor {
//获取参数值,
StdUserEmpower dataAuthRule =(StdUserEmpower) redisUtils.get("Emp_"+RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()));
String[] data = new String[]{String.join(",",dataAuthRule.getAmosOrgCode()),dataAuthRule.getRegionalCompaniesCode(),dataAuthRule.getUserId(),dataAuthRule.getAdminRegionalCompaniesCode()};
List<String> list = new ArrayList<>(Arrays.asList(data));
list.removeAll(Collections.singleton(null));
BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql");
List<String> sq ;
//获取sql
String sql = boundSql.getSql();
List<String> fileds = Arrays.asList(filed);
if (!ValidationUtil.isEmpty(dataAuthRule.getAdminRegionalCompaniesCode())) {
sq = selectSqlJXS(new String[]{fileds.get(0), fileds.get(1)}, fileCondition, Arrays.asList(data));
sq = selectSqlJXS(new String[]{fileds.get(0), fileds.get(1)}, fileCondition, list);
} else if (!ValidationUtil.isEmpty(dataAuthRule.getUserId())) {
sq = selectSqlJXS(new String[]{fileds.get(0), fileds.get(2)}, fileCondition, Arrays.asList(data));
sq = selectSqlJXS(new String[]{fileds.get(0), fileds.get(2)}, fileCondition, list);
} else {
sq = selectSqlJXS(new String[]{fileds.get(0), fileds.get(1)}, fileCondition, Arrays.asList(data));
sq = selectSqlJXS(new String[]{fileds.get(0), fileds.get(1)}, fileCondition, list);
}
String sqldata = " ";
......
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