mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
refactor: optimize FlexMapperProxy.java
This commit is contained in:
parent
16c9d720ec
commit
df79f44f32
@ -97,8 +97,8 @@ public class FlexMapperProxy<T> extends MybatisMapperProxy<T> {
|
|||||||
dbType = FlexGlobalConfig.getDefaultConfig().getDbType();
|
dbType = FlexGlobalConfig.getDefaultConfig().getDbType();
|
||||||
}
|
}
|
||||||
|
|
||||||
DialectFactory.setHintDbType(dbType);
|
|
||||||
needClearDbType = true;
|
needClearDbType = true;
|
||||||
|
DialectFactory.setHintDbType(dbType);
|
||||||
}
|
}
|
||||||
// return method.invoke(mapper, args);
|
// return method.invoke(mapper, args);
|
||||||
return cachedInvoker(method).invoke(proxy, method, args, sqlSession);
|
return cachedInvoker(method).invoke(proxy, method, args, sqlSession);
|
||||||
@ -116,26 +116,26 @@ public class FlexMapperProxy<T> extends MybatisMapperProxy<T> {
|
|||||||
|
|
||||||
|
|
||||||
private static String getConfigDataSourceKey(Method method, Object proxy) {
|
private static String getConfigDataSourceKey(Method method, Object proxy) {
|
||||||
String result = MapUtil.computeIfAbsent(methodDsKeyCache, method, method1 -> {
|
String result = MapUtil.computeIfAbsent(methodDsKeyCache, method, m -> {
|
||||||
UseDataSource useDataSource = method1.getAnnotation(UseDataSource.class);
|
UseDataSource methodAnno = method.getAnnotation(UseDataSource.class);
|
||||||
if (useDataSource != null && StringUtil.isNotBlank(useDataSource.value())) {
|
if (methodAnno != null && StringUtil.isNotBlank(methodAnno.value())) {
|
||||||
return useDataSource.value();
|
return methodAnno.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?>[] interfaces = proxy.getClass().getInterfaces();
|
Class<?>[] interfaces = proxy.getClass().getInterfaces();
|
||||||
for (Class<?> anInterface : interfaces) {
|
for (Class<?> anInterface : interfaces) {
|
||||||
UseDataSource annotation = anInterface.getAnnotation(UseDataSource.class);
|
UseDataSource classAnno = anInterface.getAnnotation(UseDataSource.class);
|
||||||
if (annotation != null) {
|
if (classAnno != null && StringUtil.isNotBlank(classAnno.value())) {
|
||||||
return annotation.value();
|
return classAnno.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interfaces[0] != RowMapper.class) {
|
if (interfaces[0] != RowMapper.class) {
|
||||||
TableInfo tableInfo = TableInfoFactory.ofMapperClass(interfaces[0]);
|
TableInfo tableInfo = TableInfoFactory.ofMapperClass(interfaces[0]);
|
||||||
if (tableInfo != null) {
|
if (tableInfo != null) {
|
||||||
String dataSourceKey = tableInfo.getDataSource();
|
String tableDsKey = tableInfo.getDataSource();
|
||||||
if (StringUtil.isNotBlank(dataSourceKey)) {
|
if (StringUtil.isNotBlank(tableDsKey)) {
|
||||||
return dataSourceKey;
|
return tableDsKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user