From dc9c7217cb19c942a23fd3f942182bd27a2e399c Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Sat, 6 Apr 2024 19:58:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20XML=20=E5=88=86=E9=A1=B5=20#{qwSql}=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=A1=A5=E5=85=85=E9=80=BB=E8=BE=91=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=AD=89=E5=8F=82=E6=95=B0=E3=80=82https://gitee.com/?= =?UTF-8?q?mybatis-flex/mybatis-flex/issues/I9DUP1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mybatisflex/core/BaseMapper.java | 14 +++++++++++--- .../java/com/mybatisflex/core/util/MapperUtil.java | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java index 313ac2bd..5e16eafa 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java @@ -21,11 +21,19 @@ import com.mybatisflex.core.field.FieldQueryBuilder; import com.mybatisflex.core.mybatis.MappedStatementTypes; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.provider.EntitySqlProvider; -import com.mybatisflex.core.query.*; +import com.mybatisflex.core.query.CPI; +import com.mybatisflex.core.query.FunctionQueryColumn; +import com.mybatisflex.core.query.Join; +import com.mybatisflex.core.query.QueryColumn; +import com.mybatisflex.core.query.QueryCondition; +import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Row; import com.mybatisflex.core.table.TableInfo; import com.mybatisflex.core.table.TableInfoFactory; -import com.mybatisflex.core.util.*; +import com.mybatisflex.core.util.ClassUtil; +import com.mybatisflex.core.util.CollectionUtil; +import com.mybatisflex.core.util.ConvertUtil; +import com.mybatisflex.core.util.MapperUtil; import org.apache.ibatis.annotations.DeleteProvider; import org.apache.ibatis.annotations.InsertProvider; import org.apache.ibatis.annotations.Param; @@ -1187,7 +1195,7 @@ public interface BaseMapper { ExecutorType executorType = FlexGlobalConfig.getDefaultConfig().getConfiguration().getDefaultExecutorType(); String mapperClassName = ClassUtil.getUsefulClass(this.getClass()).getName(); - Map preparedParams = MapperUtil.preparedParams(page, queryWrapper, otherParams); + Map preparedParams = MapperUtil.preparedParams(this, page, queryWrapper, otherParams); if (!dataSelectId.contains(".")) { dataSelectId = mapperClassName + "." + dataSelectId; } diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/MapperUtil.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/MapperUtil.java index 43988bf2..2b34a8e0 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/MapperUtil.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/MapperUtil.java @@ -33,6 +33,8 @@ import com.mybatisflex.core.query.QueryCondition; import com.mybatisflex.core.query.QueryTable; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.relation.RelationManager; +import com.mybatisflex.core.table.TableInfo; +import com.mybatisflex.core.table.TableInfoFactory; import org.apache.ibatis.exceptions.TooManyResultsException; import org.apache.ibatis.session.defaults.DefaultSqlSession; @@ -300,7 +302,7 @@ public class MapperUtil { } - public static Map preparedParams(Page page, QueryWrapper queryWrapper, Map params) { + public static Map preparedParams(BaseMapper baseMapper, Page page, QueryWrapper queryWrapper, Map params) { Map newParams = new HashMap<>(); if (params != null) { @@ -315,6 +317,8 @@ public class MapperUtil { newParams.put("dbType", dbType != null ? dbType : FlexGlobalConfig.getDefaultConfig().getDbType()); if (queryWrapper != null) { + TableInfo tableInfo = TableInfoFactory.ofMapperClass(baseMapper.getClass()); + tableInfo.appendConditions(null, queryWrapper); preparedQueryWrapper(newParams, queryWrapper); }