mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
模块化项目
This commit is contained in:
parent
c2e9435744
commit
2af3e6b7ba
@ -42,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-core</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>${mybaits-plus-join.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-annotation</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>${mybaits-plus-join.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -161,7 +161,7 @@ public class MPJInterceptor implements Interceptor {
|
||||
//移除对多查询列,为了可重复使用wrapper
|
||||
columnList.removeIf(SelectColumn::isLabel);
|
||||
List<ResultMapping> resultMappings = new ArrayList<>(columnList.size());
|
||||
columnList.forEach(i -> {
|
||||
for (SelectColumn i : columnList) {
|
||||
TableFieldInfo info = i.getTableFieldInfo();
|
||||
if (StringUtils.isNotBlank(i.getAlias())) {
|
||||
//优先别名查询 selectFunc selectAs
|
||||
@ -180,23 +180,27 @@ 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());
|
||||
StringUtils.getTargetColumn(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()) {
|
||||
if (f == null) {
|
||||
continue;
|
||||
}
|
||||
if (f.getType() == info.getField().getType()) {
|
||||
builder.typeHandler(getTypeHandler(ms, info));
|
||||
}
|
||||
}
|
||||
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<String> columnSet = resultMappings.stream().map(ResultMapping::getColumn).collect(Collectors.toSet());
|
||||
//移除result中不存在的标签
|
||||
resultMappings.removeIf(i -> !fieldMap.containsKey(i.getProperty()));
|
||||
@ -214,7 +218,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));
|
||||
}
|
||||
|
4
pom.xml
4
pom.xml
@ -5,7 +5,7 @@
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-root</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.3.0</version>
|
||||
<version>${mybaits-plus-join.version}</version>
|
||||
<name>mybatis-plus-join-root</name>
|
||||
|
||||
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
||||
@ -37,6 +37,8 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<mybaits-plus-join.version>1.3.0</mybaits-plus-join.version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<github.global.server>github</github.global.server>
|
||||
<jdkVersion>1.8</jdkVersion>
|
||||
|
Loading…
x
Reference in New Issue
Block a user