Merge branch 'dev' of https://gitee.com/log4j/pig into dev

This commit is contained in:
寻欢·李 2018-02-28 17:42:14 +08:00
commit f37918d86a
2 changed files with 12 additions and 3 deletions

View File

@ -10,6 +10,9 @@
### 详细配置 wiki
https://gitee.com/log4j/pig/wikis/
### FQA、反馈
https://gitee.com/log4j/pig/issues
### 视频教程
@ -17,6 +20,9 @@
2. [环境搭建运行展示](http://p3blpcsde.bkt.clouddn.com/2.mp4)
3. [oAuth2认证授权及其源码详解](http://p3blpcsde.bkt.clouddn.com/3.mp4)
### 默认账号admin 密码123456
### now
``` lua

View File

@ -3,6 +3,7 @@ package com.github.pig.common.bean.interceptor;
import com.baomidou.mybatisplus.plugins.SqlParserHandler;
import com.baomidou.mybatisplus.toolkit.PluginUtils;
import com.xiaoleilu.hutool.util.CollectionUtil;
import com.xiaoleilu.hutool.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql;
@ -49,9 +50,11 @@ public class DataScopeInterceptor extends SqlParserHandler implements Intercepto
} else {
String scopeName = dataScope.getScopeName();
List<Integer> deptIds = dataScope.getDeptIds();
String join = CollectionUtil.join(deptIds, ",");
originalSql = "select * from (" + originalSql + ") temp_data_scope where temp_data_scope." + scopeName + " in (" + join + ")";
metaObject.setValue("delegate.boundSql.sql", originalSql);
if(StrUtil.isNotBlank(scopeName) && CollectionUtil.isNotEmpty(deptIds)){
String join = CollectionUtil.join(deptIds, ",");
originalSql = "select * from (" + originalSql + ") temp_data_scope where temp_data_scope." + scopeName + " in (" + join + ")";
metaObject.setValue("delegate.boundSql.sql", originalSql);
}
return invocation.proceed();
}
}