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>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-core</artifactId>
|
<artifactId>mybatis-plus-join-core</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>${mybaits-plus-join.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-annotation</artifactId>
|
<artifactId>mybatis-plus-join-annotation</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>${mybaits-plus-join.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -161,7 +161,7 @@ public class MPJInterceptor implements Interceptor {
|
|||||||
//移除对多查询列,为了可重复使用wrapper
|
//移除对多查询列,为了可重复使用wrapper
|
||||||
columnList.removeIf(SelectColumn::isLabel);
|
columnList.removeIf(SelectColumn::isLabel);
|
||||||
List<ResultMapping> resultMappings = new ArrayList<>(columnList.size());
|
List<ResultMapping> resultMappings = new ArrayList<>(columnList.size());
|
||||||
columnList.forEach(i -> {
|
for (SelectColumn i : columnList) {
|
||||||
TableFieldInfo info = i.getTableFieldInfo();
|
TableFieldInfo info = i.getTableFieldInfo();
|
||||||
if (StringUtils.isNotBlank(i.getAlias())) {
|
if (StringUtils.isNotBlank(i.getAlias())) {
|
||||||
//优先别名查询 selectFunc selectAs
|
//优先别名查询 selectFunc selectAs
|
||||||
@ -180,23 +180,27 @@ public class MPJInterceptor implements Interceptor {
|
|||||||
// select selectAll selectAsClass
|
// select selectAll selectAsClass
|
||||||
if (i.getFuncEnum() == null || StringUtils.isBlank(i.getFuncEnum().getSql())) {
|
if (i.getFuncEnum() == null || StringUtils.isBlank(i.getFuncEnum().getSql())) {
|
||||||
ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), info.getProperty(),
|
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) {
|
if (info.getTypeHandler() != null && info.getTypeHandler() != UnknownTypeHandler.class) {
|
||||||
Field f = fieldMap.get(info.getProperty());
|
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));
|
builder.typeHandler(getTypeHandler(ms, info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultMappings.add(builder.build());
|
resultMappings.add(builder.build());
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
// 主键列
|
// 主键列
|
||||||
resultMappings.add(new ResultMapping.Builder(ms.getConfiguration(), i.getTagProperty(), i.getColumnName(),
|
resultMappings.add(new ResultMapping.Builder(ms.getConfiguration(), i.getTagProperty(),
|
||||||
i.getKeyType()).build());
|
StringUtils.getTargetColumn(i.getColumnName()), i.getKeyType()).build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
Set<String> columnSet = resultMappings.stream().map(ResultMapping::getColumn).collect(Collectors.toSet());
|
Set<String> columnSet = resultMappings.stream().map(ResultMapping::getColumn).collect(Collectors.toSet());
|
||||||
//移除result中不存在的标签
|
//移除result中不存在的标签
|
||||||
resultMappings.removeIf(i -> !fieldMap.containsKey(i.getProperty()));
|
resultMappings.removeIf(i -> !fieldMap.containsKey(i.getProperty()));
|
||||||
@ -214,7 +218,8 @@ public class MPJInterceptor implements Interceptor {
|
|||||||
columnName = getColumn(columnSet, columnName);
|
columnName = getColumn(columnSet, columnName);
|
||||||
columnList.add(SelectColumn.of(mpjColl.getEntityClass(), r.getColumn(), null,
|
columnList.add(SelectColumn.of(mpjColl.getEntityClass(), r.getColumn(), null,
|
||||||
Objects.equals(columnName, r.getColumn()) ? null : columnName, null, null, true, 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标签
|
if (r.isId()) {//主键标记为id标签
|
||||||
builder.flags(Collections.singletonList(ResultFlag.ID));
|
builder.flags(Collections.singletonList(ResultFlag.ID));
|
||||||
}
|
}
|
||||||
|
4
pom.xml
4
pom.xml
@ -5,7 +5,7 @@
|
|||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-root</artifactId>
|
<artifactId>mybatis-plus-join-root</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.3.0</version>
|
<version>${mybaits-plus-join.version}</version>
|
||||||
<name>mybatis-plus-join-root</name>
|
<name>mybatis-plus-join-root</name>
|
||||||
|
|
||||||
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
||||||
@ -37,6 +37,8 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<mybaits-plus-join.version>1.3.0</mybaits-plus-join.version>
|
||||||
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<github.global.server>github</github.global.server>
|
<github.global.server>github</github.global.server>
|
||||||
<jdkVersion>1.8</jdkVersion>
|
<jdkVersion>1.8</jdkVersion>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user