日志
This commit is contained in:
parent
f8c29798f9
commit
7a2b8f47fe
@ -1,5 +1,6 @@
|
|||||||
package com.zhgd.mybatis;
|
package com.zhgd.mybatis;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
|
import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
|
||||||
@ -69,6 +70,25 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getCallPosition() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
for (StackTraceElement e : stackTrace) {
|
||||||
|
if (e.getClassName().startsWith("com.zhgd.xmgl")) {
|
||||||
|
sb.append(e.getClassName());
|
||||||
|
sb.append(".");
|
||||||
|
sb.append(e.getMethodName());
|
||||||
|
sb.append("(");
|
||||||
|
sb.append(StrUtil.subAfter(e.getClassName(), ".", true));
|
||||||
|
sb.append(".java:");
|
||||||
|
sb.append(e.getLineNumber());
|
||||||
|
sb.append(")");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) {
|
public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) {
|
||||||
PluginUtils.MPStatementHandler mpSh = PluginUtils.mpStatementHandler(sh);
|
PluginUtils.MPStatementHandler mpSh = PluginUtils.mpStatementHandler(sh);
|
||||||
MappedStatement ms = mpSh.mappedStatement();
|
MappedStatement ms = mpSh.mappedStatement();
|
||||||
@ -108,7 +128,7 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
|||||||
Method[] declaredMethods = clazz.getDeclaredMethods();
|
Method[] declaredMethods = clazz.getDeclaredMethods();
|
||||||
Optional<DataScope> dsOption = Arrays.stream(declaredMethods).filter(method -> method.getName().equals(methodName)).map(method -> method.getAnnotation(DataScope.class)).filter(Objects::nonNull).findFirst();
|
Optional<DataScope> dsOption = Arrays.stream(declaredMethods).filter(method -> method.getName().equals(methodName)).map(method -> method.getAnnotation(DataScope.class)).filter(Objects::nonNull).findFirst();
|
||||||
annotation = dsOption.orElseGet(() -> clazz.getAnnotation(DataScope.class));
|
annotation = dsOption.orElseGet(() -> clazz.getAnnotation(DataScope.class));
|
||||||
log.debug("mapper查询方法: {} # {}", clazz.getName(), methodName);
|
log.debug("查询mapper方法: {} >>> {}#{}", getCallPosition(), clazz.getName(), methodName);
|
||||||
if (findIgnoreDataScope(parameter, annotation) && isNotSqlTest()) {
|
if (findIgnoreDataScope(parameter, annotation) && isNotSqlTest()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user