This commit is contained in:
admin 2021-02-20 15:35:46 +08:00
parent 3b2f9fcd45
commit dbbe8f2341
5 changed files with 36 additions and 32 deletions

View File

@ -74,6 +74,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* {@link com.github.yulichang.common.JoinAbstractLambdaWrapper} * {@link com.github.yulichang.common.JoinAbstractLambdaWrapper}
* {@link com.github.yulichang.wrapper.interfaces.Compare} * {@link com.github.yulichang.wrapper.interfaces.Compare}
* {@link com.github.yulichang.wrapper.interfaces.Func} * {@link com.github.yulichang.wrapper.interfaces.Func}
* {@link com.github.yulichang.toolkit.LambdaUtils}
* <p> * <p>
* *
* @author yulichang * @author yulichang

View File

@ -2,13 +2,14 @@
### 使用方法 ### 使用方法
#### 如需单独使用 请拷贝以下5个类 #### 如需单独使用 请拷贝以下6个类
[com.github.yulichang.common.JoinLambdaWrapper](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/common/JoinLambdaWrapper.java) [com.github.yulichang.common.JoinLambdaWrapper](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/common/JoinLambdaWrapper.java)
[com.github.yulichang.common.JoinAbstractWrapper](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/common/JoinAbstractLambdaWrapper.java) [com.github.yulichang.common.JoinAbstractWrapper](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/common/JoinAbstractLambdaWrapper.java)
[com.github.yulichang.common.JoinAbstractLambdaWrapper](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/common/JoinAbstractLambdaWrapper.java) [com.github.yulichang.common.JoinAbstractLambdaWrapper](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/common/JoinAbstractLambdaWrapper.java)
[com.github.yulichang.wrapper.interfaces.Compare](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/wrapper/interfaces/Compare.java) [com.github.yulichang.wrapper.interfaces.Compare](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/wrapper/interfaces/Compare.java)
[com.github.yulichang.wrapper.interfaces.Func](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/wrapper/interfaces/Func.java) [com.github.yulichang.wrapper.interfaces.Func](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/wrapper/interfaces/Func.java)
[com.github.yulichang.toolkit.LambdaUtils](https://gitee.com/best_handsome/mybatis-plus-join/blob/master/src/main/java/com/github/yulichang/toolkit/LambdaUtils.java)
#### 不使用表别名 #### 不使用表别名
@ -27,7 +28,6 @@ public interface UserMapper extends BaseMapper<UserDO> {
或者xml 或者xml
``` ```
<select id="userLeftJoin" resultType="UserDTO"> <select id="userLeftJoin" resultType="UserDTO">
select select
user.*, user.*,

View File

@ -11,21 +11,20 @@ import java.util.Objects;
/** /**
* @author yulichang * @author yulichang
* @see com.baomidou.mybatisplus.core.toolkit.LambdaUtils * @see com.baomidou.mybatisplus.core.toolkit.LambdaUtils
* @see PropertyNamer * @see org.apache.ibatis.reflection.property.PropertyNamer
*/ */
public final class LambdaUtils { public final class LambdaUtils {
/** /**
* 获取lambda属性名 * 获取属性名
*/ */
public static <T> String getName(SFunction<T, ?> fn) { public static <T> String getName(SFunction<T, ?> fn) {
return PropertyNamer.methodToProperty(com.baomidou.mybatisplus.core.toolkit.LambdaUtils.resolve(fn).getImplMethodName()); return PropertyNamer.methodToProperty(com.baomidou.mybatisplus.core.toolkit.LambdaUtils.resolve(fn).getImplMethodName());
} }
/** /**
* 获取列明 * 获取列名
* 优先获取tableField中的值
*/ */
public static <T> String getColumn(SFunction<T, ?> fn) { public static <T> String getColumn(SFunction<T, ?> fn) {
SerializedLambda lambda = com.baomidou.mybatisplus.core.toolkit.LambdaUtils.resolve(fn); SerializedLambda lambda = com.baomidou.mybatisplus.core.toolkit.LambdaUtils.resolve(fn);

View File

@ -7,6 +7,8 @@ import java.util.Map;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
/** /**
* 将原来的泛型R改成SFunction<R, ?>
* <p>
* {@link com.baomidou.mybatisplus.core.conditions.interfaces.Compare} * {@link com.baomidou.mybatisplus.core.conditions.interfaces.Compare}
*/ */
public interface Compare<Children> extends Serializable { public interface Compare<Children> extends Serializable {

View File

@ -11,6 +11,8 @@ import java.util.function.Consumer;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
/** /**
* 将原来的泛型R改成SFunction<R, ?>
* <p>
* copy {@link com.baomidou.mybatisplus.core.conditions.interfaces.Func} * copy {@link com.baomidou.mybatisplus.core.conditions.interfaces.Func}
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -19,7 +21,7 @@ public interface Func<Children> extends Serializable {
/** /**
* ignore * ignore
*/ */
default <R> Children isNull(SFunction<R,?> column) { default <R> Children isNull(SFunction<R, ?> column) {
return isNull(true, column); return isNull(true, column);
} }
@ -31,12 +33,12 @@ public interface Func<Children> extends Serializable {
* @param column 字段 * @param column 字段
* @return children * @return children
*/ */
<R> Children isNull(boolean condition, SFunction<R,?> column); <R> Children isNull(boolean condition, SFunction<R, ?> column);
/** /**
* ignore * ignore
*/ */
default <R> Children isNotNull(SFunction<R,?> column) { default <R> Children isNotNull(SFunction<R, ?> column) {
return isNotNull(true, column); return isNotNull(true, column);
} }
@ -48,12 +50,12 @@ public interface Func<Children> extends Serializable {
* @param column 字段 * @param column 字段
* @return children * @return children
*/ */
<R> Children isNotNull(boolean condition, SFunction<R,?> column); <R> Children isNotNull(boolean condition, SFunction<R, ?> column);
/** /**
* ignore * ignore
*/ */
default <R> Children in(SFunction<R,?> column, Collection<?> coll) { default <R> Children in(SFunction<R, ?> column, Collection<?> coll) {
return in(true, column, coll); return in(true, column, coll);
} }
@ -68,12 +70,12 @@ public interface Func<Children> extends Serializable {
* @param coll 数据集合 * @param coll 数据集合
* @return children * @return children
*/ */
<R> Children in(boolean condition, SFunction<R,?> column, Collection<?> coll); <R> Children in(boolean condition, SFunction<R, ?> column, Collection<?> coll);
/** /**
* ignore * ignore
*/ */
default <R> Children in(SFunction<R,?> column, Object... values) { default <R> Children in(SFunction<R, ?> column, Object... values) {
return in(true, column, values); return in(true, column, values);
} }
@ -88,7 +90,7 @@ public interface Func<Children> extends Serializable {
* @param values 数据数组 * @param values 数据数组
* @return children * @return children
*/ */
default <R> Children in(boolean condition, SFunction<R,?> column, Object... values) { default <R> Children in(boolean condition, SFunction<R, ?> column, Object... values) {
return in(condition, column, Arrays.stream(Optional.ofNullable(values).orElseGet(() -> new Object[]{})) return in(condition, column, Arrays.stream(Optional.ofNullable(values).orElseGet(() -> new Object[]{}))
.collect(toList())); .collect(toList()));
} }
@ -96,7 +98,7 @@ public interface Func<Children> extends Serializable {
/** /**
* ignore * ignore
*/ */
default <R> Children notIn(SFunction<R,?> column, Collection<?> coll) { default <R> Children notIn(SFunction<R, ?> column, Collection<?> coll) {
return notIn(true, column, coll); return notIn(true, column, coll);
} }
@ -109,12 +111,12 @@ public interface Func<Children> extends Serializable {
* @param coll 数据集合 * @param coll 数据集合
* @return children * @return children
*/ */
<R> Children notIn(boolean condition, SFunction<R,?> column, Collection<?> coll); <R> Children notIn(boolean condition, SFunction<R, ?> column, Collection<?> coll);
/** /**
* ignore * ignore
*/ */
default <R> Children notIn(SFunction<R,?> column, Object... value) { default <R> Children notIn(SFunction<R, ?> column, Object... value) {
return notIn(true, column, value); return notIn(true, column, value);
} }
@ -127,7 +129,7 @@ public interface Func<Children> extends Serializable {
* @param values 数据数组 * @param values 数据数组
* @return children * @return children
*/ */
default <R> Children notIn(boolean condition, SFunction<R,?> column, Object... values) { default <R> Children notIn(boolean condition, SFunction<R, ?> column, Object... values) {
return notIn(condition, column, Arrays.stream(Optional.ofNullable(values).orElseGet(() -> new Object[]{})) return notIn(condition, column, Arrays.stream(Optional.ofNullable(values).orElseGet(() -> new Object[]{}))
.collect(toList())); .collect(toList()));
} }
@ -135,7 +137,7 @@ public interface Func<Children> extends Serializable {
/** /**
* ignore * ignore
*/ */
default <R> Children inSql(SFunction<R,?> column, String inValue) { default <R> Children inSql(SFunction<R, ?> column, String inValue) {
return inSql(true, column, inValue); return inSql(true, column, inValue);
} }
@ -150,12 +152,12 @@ public interface Func<Children> extends Serializable {
* @param inValue sql语句 * @param inValue sql语句
* @return children * @return children
*/ */
<R> Children inSql(boolean condition, SFunction<R,?> column, String inValue); <R> Children inSql(boolean condition, SFunction<R, ?> column, String inValue);
/** /**
* ignore * ignore
*/ */
default <R> Children notInSql(SFunction<R,?> column, String inValue) { default <R> Children notInSql(SFunction<R, ?> column, String inValue) {
return notInSql(true, column, inValue); return notInSql(true, column, inValue);
} }
@ -170,19 +172,19 @@ public interface Func<Children> extends Serializable {
* @param inValue sql语句 ---&gt; 1,2,3,4,5,6 或者 select id from table where id &lt; 3 * @param inValue sql语句 ---&gt; 1,2,3,4,5,6 或者 select id from table where id &lt; 3
* @return children * @return children
*/ */
<R> Children notInSql(boolean condition, SFunction<R,?> column, String inValue); <R> Children notInSql(boolean condition, SFunction<R, ?> column, String inValue);
/** /**
* ignore * ignore
*/ */
default <R> Children groupBy(SFunction<R,?> column) { default <R> Children groupBy(SFunction<R, ?> column) {
return groupBy(true, column); return groupBy(true, column);
} }
/** /**
* ignore * ignore
*/ */
default <R> Children groupBy(SFunction<R,?>... columns) { default <R> Children groupBy(SFunction<R, ?>... columns) {
return groupBy(true, columns); return groupBy(true, columns);
} }
@ -194,19 +196,19 @@ public interface Func<Children> extends Serializable {
* @param columns 字段数组 * @param columns 字段数组
* @return children * @return children
*/ */
<R> Children groupBy(boolean condition, SFunction<R,?>... columns); <R> Children groupBy(boolean condition, SFunction<R, ?>... columns);
/** /**
* ignore * ignore
*/ */
default <R> Children orderByAsc(SFunction<R,?> column) { default <R> Children orderByAsc(SFunction<R, ?> column) {
return orderByAsc(true, column); return orderByAsc(true, column);
} }
/** /**
* ignore * ignore
*/ */
default <R> Children orderByAsc(SFunction<R,?>... columns) { default <R> Children orderByAsc(SFunction<R, ?>... columns) {
return orderByAsc(true, columns); return orderByAsc(true, columns);
} }
@ -218,21 +220,21 @@ public interface Func<Children> extends Serializable {
* @param columns 字段数组 * @param columns 字段数组
* @return children * @return children
*/ */
default <R> Children orderByAsc(boolean condition, SFunction<R,?>... columns) { default <R> Children orderByAsc(boolean condition, SFunction<R, ?>... columns) {
return orderBy(condition, true, columns); return orderBy(condition, true, columns);
} }
/** /**
* ignore * ignore
*/ */
default <R> Children orderByDesc(SFunction<R,?> column) { default <R> Children orderByDesc(SFunction<R, ?> column) {
return orderByDesc(true, column); return orderByDesc(true, column);
} }
/** /**
* ignore * ignore
*/ */
default <R> Children orderByDesc(SFunction<R,?>... columns) { default <R> Children orderByDesc(SFunction<R, ?>... columns) {
return orderByDesc(true, columns); return orderByDesc(true, columns);
} }
@ -244,7 +246,7 @@ public interface Func<Children> extends Serializable {
* @param columns 字段数组 * @param columns 字段数组
* @return children * @return children
*/ */
default <R> Children orderByDesc(boolean condition, SFunction<R,?>... columns) { default <R> Children orderByDesc(boolean condition, SFunction<R, ?>... columns) {
return orderBy(condition, false, columns); return orderBy(condition, false, columns);
} }
@ -257,7 +259,7 @@ public interface Func<Children> extends Serializable {
* @param columns 字段数组 * @param columns 字段数组
* @return children * @return children
*/ */
<R> Children orderBy(boolean condition, boolean isAsc, SFunction<R,?>... columns); <R> Children orderBy(boolean condition, boolean isAsc, SFunction<R, ?>... columns);
/** /**
* ignore * ignore