diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/MybatisLabel.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/MybatisLabel.java index 7059307..1e68ee9 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/MybatisLabel.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/MybatisLabel.java @@ -251,7 +251,7 @@ public class MybatisLabel implements Label { result.setBaseColumn(mybatisLabel.baseColumn); result.setProperty(i.getColumProperty()); result.setJavaType(i.getColumnType()); - result.setJdbcType(Objects.isNull(i.getTableFieldInfo()) ? null : i.getTableFieldInfo().getJdbcType()); + result.setJdbcType(i.getJdbcType()); result.setSelectNormal(i); return result; }).collect(Collectors.toList())); diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/Result.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/Result.java index af87f52..ee9a820 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/Result.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/apt/resultmap/Result.java @@ -1,6 +1,5 @@ package com.github.yulichang.wrapper.apt.resultmap; -import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.github.yulichang.apt.BaseColumn; @@ -16,7 +15,6 @@ import org.apache.ibatis.type.JdbcType; import java.util.Map; import java.util.Objects; -import java.util.Optional; /** * result 标签 @@ -71,7 +69,7 @@ public class Result implements IResult { result.selectNormal = selectCache; result.property = selectCache.getColumProperty(); result.javaType = selectCache.getColumnType(); - result.jdbcType = Optional.ofNullable(selectCache.getTableFieldInfo()).map(TableFieldInfo::getJdbcType).orElse(null); + result.jdbcType = selectCache.getJdbcType(); } public Builder(boolean isId, BaseColumn baseColumn, SelectCache selectCache) { @@ -82,7 +80,7 @@ public class Result implements IResult { result.selectNormal = selectCache; result.property = selectCache.getColumProperty(); result.javaType = selectCache.getColumnType(); - result.jdbcType = Optional.ofNullable(selectCache.getTableFieldInfo()).map(TableFieldInfo::getJdbcType).orElse(null); + result.jdbcType = selectCache.getJdbcType(); } public Builder property(SFunction property) { @@ -102,7 +100,7 @@ public class Result implements IResult { result.javaType = normal.getColumnType(); } if (Objects.isNull(result.jdbcType)) { - result.jdbcType = Objects.isNull(normal.getTableFieldInfo()) ? null : normal.getTableFieldInfo().getJdbcType(); + result.jdbcType = normal.getJdbcType(); } return this; } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java index f6fafb0..ad2eb8e 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java @@ -1,10 +1,12 @@ package com.github.yulichang.wrapper.interfaces; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.github.yulichang.interfaces.MPJBaseJoin; import com.github.yulichang.toolkit.SqlHelper; import java.util.List; +import java.util.Optional; /** * 链式调用 @@ -62,7 +64,7 @@ public interface Chain extends MPJBaseJoin { * JoinWrappers.lambda(User.class)
*/ default T first() { - return list().stream().findFirst().orElse(null); + return Optional.of(list()).filter(CollectionUtils::isNotEmpty).map(m -> m.get(0)).orElse(null); } /** @@ -73,7 +75,7 @@ public interface Chain extends MPJBaseJoin { * JoinWrappers.lambda(User.class)
*/ default R first(Class resultType) { - return list(resultType).stream().findFirst().orElse(null); + return Optional.of(list(resultType)).filter(CollectionUtils::isNotEmpty).map(m -> m.get(0)).orElse(null); } /** diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java index 4d9bf51..c7e328b 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java @@ -1,9 +1,9 @@ package com.github.yulichang.wrapper.segments; -import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; import com.github.yulichang.apt.BaseColumn; import com.github.yulichang.apt.Column; import com.github.yulichang.wrapper.enums.BaseFuncEnum; +import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.TypeHandler; import java.io.Serializable; @@ -42,7 +42,9 @@ public interface Select extends Serializable { String getAlias(); - TableFieldInfo getTableFieldInfo(); + Class getPropertyType(); + + JdbcType getJdbcType(); boolean isFunc(); diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectApt.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectApt.java index 3b34896..f95bb76 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectApt.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectApt.java @@ -1,11 +1,11 @@ package com.github.yulichang.wrapper.segments; -import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; import com.github.yulichang.apt.BaseColumn; import com.github.yulichang.apt.Column; import com.github.yulichang.wrapper.enums.BaseFuncEnum; import lombok.Getter; import lombok.Setter; +import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.TypeHandler; /** @@ -194,9 +194,17 @@ public class SelectApt implements Select { } @Override - public TableFieldInfo getTableFieldInfo() { + public Class getPropertyType() { if (cache != null) { - return cache.getTableFieldInfo(); + return cache.getPropertyType(); + } + return null; + } + + @Override + public JdbcType getJdbcType() { + if (cache != null) { + return cache.getJdbcType(); } return null; } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java index f854c44..9e15fec 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java @@ -1,10 +1,10 @@ package com.github.yulichang.wrapper.segments; -import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; import com.github.yulichang.apt.BaseColumn; import com.github.yulichang.wrapper.enums.BaseFuncEnum; import lombok.Getter; +import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.TypeHandler; /** @@ -43,7 +43,7 @@ public class SelectLabel implements Select { this.baseColumn = baseColumn; } - public SelectLabel(SelectCache cache, Integer index, Class tagClass, String column, boolean hasTableAlias, String tableAlias) { + public SelectLabel(SelectCache cache, Integer index, Class tagClass, String column, boolean hasTableAlias, String tableAlias, BaseColumn baseColumn) { this.cache = cache; this.index = index; this.tagClass = tagClass;