diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MappingConfig.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MappingConfig.java
index 3d8d63e..64d31fb 100644
--- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MappingConfig.java
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MappingConfig.java
@@ -14,7 +14,7 @@ public class MappingConfig {
public MappingConfig() {
TableInfoHelper.getTableInfos().forEach(i ->
- MPJTableInfoHelper.initTableInfo(i.getEntityType(), MPJTableMapperHelper.get(i.getEntityType())));
+ MPJTableInfoHelper.initTableInfo(i.getEntityType(), MPJTableMapperHelper.getMapper(i.getEntityType())));
}
}
diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java
index 8a35340..0f3aba6 100644
--- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java
@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.toolkit.*;
import com.github.yulichang.interfaces.MPJBaseJoin;
+import com.github.yulichang.mapper.MPJTableMapperHelper;
import com.github.yulichang.method.MPJResultType;
+import com.github.yulichang.query.MPJQueryWrapper;
import com.github.yulichang.toolkit.Constant;
import com.github.yulichang.toolkit.MPJReflectionKit;
import com.github.yulichang.toolkit.support.SelectColumn;
@@ -93,14 +95,26 @@ public class MPJInterceptor implements Interceptor {
/**
* 获取MappedStatement
*/
+ @SuppressWarnings("rawtypes")
public MappedStatement getMappedStatement(MappedStatement ms, Class> resultType, Object ew) {
String id = ms.getId() + StringPool.UNDERSCORE + resultType.getName();
-
- if (ew instanceof MPJLambdaWrapper && ((MPJLambdaWrapper>) ew).isResultMap()) {
+ if (ew instanceof MPJLambdaWrapper) {
+ MPJLambdaWrapper wrapper = (MPJLambdaWrapper) ew;
+ wrapper.setEntityClass(MPJTableMapperHelper.getEntity(getEntity(ms.getId())));
+ //TODO 重构缓存 -> 根据sql缓存
//不走缓存
- return buildMappedStatement(ms, resultType, ew, id);
}
- //走缓存
+ if (ew instanceof MPJQueryWrapper) {
+ MPJQueryWrapper wrapper = (MPJQueryWrapper) ew;
+ return getCache(ms, id + wrapper.getSqlSelect(), resultType, ew);
+ }
+ return buildMappedStatement(ms, resultType, ew, id);
+ }
+
+ /**
+ * 走缓存
+ */
+ private MappedStatement getCache(MappedStatement ms, String id, Class> resultType, Object ew) {
Map
* 例 leftJoin(UserDO.class, on -> on.eq(UserDO::getId,UserAddressDO::getUserId).le().gt()...)
*
* @param clazz 关联实体类
* @param function 条件
*/
- default