diff --git a/pom.xml b/pom.xml index 4aa77b1..758701e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.yulichang mybatis-plus-join - 1.3.1 + 1.3.2 mybatis-plus-join An enhanced toolkit of Mybatis-Plus to simplify development. https://github.com/yulichang/mybatis-plus-join @@ -52,144 +52,4 @@ provided - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true - - ossrh - https://oss.sonatype.org/ - true - 30 - - - - - - - disable-javadoc-doclint - - [1.8,) - - - -Xdoclint:none - - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true - - ossrh - https://oss.sonatype.org/ - true - 30 - - - - - - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - diff --git a/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java b/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java index 7184c9f..94a860d 100644 --- a/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java +++ b/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java @@ -161,15 +161,18 @@ public class MPJInterceptor implements Interceptor { //移除对多查询列,为了可重复使用wrapper columnList.removeIf(SelectColumn::isLabel); List resultMappings = new ArrayList<>(columnList.size()); - columnList.forEach(i -> { + for (SelectColumn i : columnList) { TableFieldInfo info = i.getTableFieldInfo(); if (StringUtils.isNotBlank(i.getAlias())) { //优先别名查询 selectFunc selectAs ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), i.getAlias(), i.getAlias(), getAliasField(resultType, fieldMap, i.getAlias())); if (i.getFuncEnum() == null || StringUtils.isBlank(i.getFuncEnum().getSql())) { + Field f = fieldMap.get(i.getAlias()); + if (f == null) { + continue; + } if (info != null && info.getTypeHandler() != null && info.getTypeHandler() != UnknownTypeHandler.class) { - Field f = fieldMap.get(i.getAlias()); if (f.getType() == info.getField().getType()) { builder.typeHandler(getTypeHandler(ms, info)); } @@ -180,23 +183,28 @@ public class MPJInterceptor implements Interceptor { // select selectAll selectAsClass if (i.getFuncEnum() == null || StringUtils.isBlank(i.getFuncEnum().getSql())) { ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), info.getProperty(), - info.getColumn(), info.getPropertyType()); - if (info.getTypeHandler() != null && info.getTypeHandler() != UnknownTypeHandler.class) { - Field f = fieldMap.get(info.getProperty()); - if (f != null && f.getType() == info.getField().getType()) { + StringUtils.getTargetColumn(info.getColumn()), info.getPropertyType()); + Field f = fieldMap.get(info.getProperty()); + if (f == null) { + continue; + } + if (f.getType() == info.getField().getType()) { + if (info.getTypeHandler() != null && info.getTypeHandler() != UnknownTypeHandler.class) { builder.typeHandler(getTypeHandler(ms, info)); } } + builder.javaType(f.getType()); resultMappings.add(builder.build()); } else { - resultMappings.add(new ResultMapping.Builder(ms.getConfiguration(), info.getProperty(), info.getColumn(), info.getPropertyType()).build()); + resultMappings.add(new ResultMapping.Builder(ms.getConfiguration(), info.getProperty(), + StringUtils.getTargetColumn(info.getColumn()), info.getPropertyType()).build()); } } else { // 主键列 - resultMappings.add(new ResultMapping.Builder(ms.getConfiguration(), i.getTagProperty(), i.getColumnName(), - i.getKeyType()).build()); + resultMappings.add(new ResultMapping.Builder(ms.getConfiguration(), i.getTagProperty(), + StringUtils.getTargetColumn(i.getColumnName()), i.getKeyType()).build()); } - }); + } Set columnSet = resultMappings.stream().map(ResultMapping::getColumn).collect(Collectors.toSet()); //移除result中不存在的标签 resultMappings.removeIf(i -> !fieldMap.containsKey(i.getProperty())); @@ -214,7 +222,8 @@ public class MPJInterceptor implements Interceptor { columnName = getColumn(columnSet, columnName); columnList.add(SelectColumn.of(mpjColl.getEntityClass(), r.getColumn(), null, Objects.equals(columnName, r.getColumn()) ? null : columnName, null, null, true, null)); - ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), r.getProperty(), columnName, r.getJavaType()); + ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), r.getProperty(), + StringUtils.getTargetColumn(columnName), r.getJavaType()); if (r.isId()) {//主键标记为id标签 builder.flags(Collections.singletonList(ResultFlag.ID)); }