mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
style: 简化代码
This commit is contained in:
parent
a500230a6b
commit
c8a21424af
@ -24,6 +24,7 @@ import com.github.yulichang.toolkit.sql.SqlScriptUtils;
|
||||
import com.github.yulichang.wrapper.enums.IfExistsSqlKeyWordEnum;
|
||||
import com.github.yulichang.wrapper.enums.PrefixEnum;
|
||||
import com.github.yulichang.wrapper.interfaces.CompareStrIfExists;
|
||||
import com.github.yulichang.wrapper.interfaces.DoSomething;
|
||||
import com.github.yulichang.wrapper.interfaces.FuncStr;
|
||||
import com.github.yulichang.wrapper.interfaces.Join;
|
||||
import com.github.yulichang.wrapper.segments.SelectFunc;
|
||||
@ -793,15 +794,6 @@ public abstract class KtAbstractWrapper<T, Children extends KtAbstractWrapper<T,
|
||||
return SerializationUtils.clone(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 做事函数
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface DoSomething {
|
||||
|
||||
void doIt();
|
||||
}
|
||||
|
||||
/* ************************* on语句重载 *************************** */
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,7 @@ import com.github.yulichang.interfaces.MPJBaseJoin;
|
||||
import com.github.yulichang.kt.KtAbstractLambdaWrapper;
|
||||
import com.github.yulichang.query.interfaces.StringJoin;
|
||||
import com.github.yulichang.toolkit.Constant;
|
||||
import com.github.yulichang.wrapper.interfaces.WrapperFunction;
|
||||
import com.github.yulichang.wrapper.interfaces.MFunction;
|
||||
import kotlin.reflect.KProperty;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
@ -45,7 +45,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件`
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children leftJoin(Class<?> clazz, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.LEFT_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children leftJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.LEFT_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children leftJoin(Class<?> clazz, String alias, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.LEFT_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children leftJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.LEFT_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -146,14 +146,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children rightJoin(Class<?> clazz, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children rightJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -181,14 +181,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children rightJoin(Class<?> clazz, String alias, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children rightJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -218,14 +218,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children innerJoin(Class<?> clazz, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.INNER_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children innerJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.INNER_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -254,14 +254,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children innerJoin(Class<?> clazz, String alias, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.INNER_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children innerJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.INNER_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -289,14 +289,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children fullJoin(Class<?> clazz, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.FULL_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children fullJoin(Class<?> clazz, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.FULL_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -324,14 +324,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children fullJoin(Class<?> clazz, String alias, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.FULL_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children fullJoin(Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(Constant.FULL_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default Children join(String keyWord, Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children join(String keyWord, Class<?> clazz, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(keyWord, clazz, (on, e) -> function.apply(on));
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default Children join(String keyWord, Class<?> clazz, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children join(String keyWord, Class<?> clazz, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(keyWord, clazz, (on, e) -> {
|
||||
on.eq(left, right);
|
||||
ext.apply(e);
|
||||
@ -420,7 +420,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default Children join(String keyWord, Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children join(String keyWord, Class<?> clazz, String alias, MFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(keyWord, clazz, alias, (on, e) -> function.apply(on));
|
||||
}
|
||||
|
||||
@ -431,7 +431,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default Children join(String keyWord, Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, WrapperFunction<Children> ext) {
|
||||
default Children join(String keyWord, Class<?> clazz, String alias, KProperty<?> left, KProperty<?> right, MFunction<Children> ext) {
|
||||
return join(keyWord, clazz, alias, (on, e) -> {
|
||||
on.eq(left, right);
|
||||
ext.apply(e);
|
||||
|
@ -7,8 +7,8 @@ import com.github.yulichang.kt.resultmap.MybatisLabelFree;
|
||||
import com.github.yulichang.toolkit.KtUtils;
|
||||
import com.github.yulichang.toolkit.MPJReflectionKit;
|
||||
import com.github.yulichang.toolkit.support.FieldCache;
|
||||
import com.github.yulichang.wrapper.interfaces.MFunction;
|
||||
import com.github.yulichang.wrapper.resultmap.Label;
|
||||
import com.github.yulichang.wrapper.resultmap.MFunc;
|
||||
import kotlin.reflect.KProperty;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -92,11 +92,11 @@ public interface QueryLabel<Children> {
|
||||
*/
|
||||
default Children selectCollection(Class<?> child,
|
||||
KProperty<?> dtoField,
|
||||
MFunc<MybatisLabel.Builder<?, ?>> collection) {
|
||||
MFunction<MybatisLabel.Builder<?, ?>> collection) {
|
||||
return selectCollection(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
default Children selectCollection(KProperty<?> dtoField, MFunc<MybatisLabelFree.Builder<?>> collection) {
|
||||
default Children selectCollection(KProperty<?> dtoField, MFunction<MybatisLabelFree.Builder<?>> collection) {
|
||||
//自由映射必须存在泛型Z
|
||||
String dtoFieldName = dtoField.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(dtoField)).get(dtoFieldName);
|
||||
@ -111,7 +111,7 @@ public interface QueryLabel<Children> {
|
||||
default Children selectCollection(String prefix,
|
||||
Class<?> child,
|
||||
KProperty<?> dtoField,
|
||||
MFunc<MybatisLabel.Builder<?, ?>> collection) {
|
||||
MFunction<MybatisLabel.Builder<?, ?>> collection) {
|
||||
String dtoFieldName = dtoField.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(dtoField)).get(dtoFieldName);
|
||||
//获取集合泛型
|
||||
@ -149,12 +149,12 @@ public interface QueryLabel<Children> {
|
||||
* @since 1.3.0
|
||||
*/
|
||||
default Children selectAssociation(Class<?> child, KProperty<?> dtoField,
|
||||
MFunc<MybatisLabel.Builder<?, ?>> collection) {
|
||||
MFunction<MybatisLabel.Builder<?, ?>> collection) {
|
||||
return selectAssociation(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
default Children selectAssociation(KProperty<?> dtoField,
|
||||
MFunc<MybatisLabelFree.Builder<?>> collection) {
|
||||
MFunction<MybatisLabelFree.Builder<?>> collection) {
|
||||
String dtoFieldName = dtoField.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(dtoField)).get(dtoFieldName);
|
||||
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
||||
@ -165,7 +165,7 @@ public interface QueryLabel<Children> {
|
||||
}
|
||||
|
||||
default Children selectAssociation(String prefix, Class<?> child, KProperty<?> dtoField,
|
||||
MFunc<MybatisLabel.Builder<?, ?>> collection) {
|
||||
MFunction<MybatisLabel.Builder<?, ?>> collection) {
|
||||
String dtoFieldName = dtoField.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(dtoField)).get(dtoFieldName);
|
||||
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
||||
|
@ -8,9 +8,9 @@ import com.github.yulichang.toolkit.MPJReflectionKit;
|
||||
import com.github.yulichang.toolkit.TableHelper;
|
||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||
import com.github.yulichang.toolkit.support.FieldCache;
|
||||
import com.github.yulichang.wrapper.interfaces.MFunction;
|
||||
import com.github.yulichang.wrapper.resultmap.IResult;
|
||||
import com.github.yulichang.wrapper.resultmap.Label;
|
||||
import com.github.yulichang.wrapper.resultmap.MFunc;
|
||||
import com.github.yulichang.wrapper.segments.SelectCache;
|
||||
import kotlin.reflect.KProperty;
|
||||
import lombok.Getter;
|
||||
@ -160,7 +160,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public <A, R> Builder<E, T> collection(Class<A> entityClass, KProperty<?> func, MFunc<Builder<A, R>> mFunc) {
|
||||
public <A, R> Builder<E, T> collection(Class<A> entityClass, KProperty<?> func, MFunction<Builder<A, R>> mFunc) {
|
||||
return collection(null, entityClass, func, mFunc);
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public <A, R> Builder<E, T> collection(KProperty<?> func,
|
||||
MFunc<MybatisLabelFree.Builder<R>> mFunc) {
|
||||
MFunction<MybatisLabelFree.Builder<R>> mFunc) {
|
||||
String dtoFieldName = func.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(func)).get(dtoFieldName);
|
||||
//获取集合泛型
|
||||
@ -185,7 +185,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
public <A, R> Builder<E, T> collection(String prefix,
|
||||
Class<A> entityClass,
|
||||
KProperty<?> func,
|
||||
MFunc<Builder<A, R>> mFunc) {
|
||||
MFunction<Builder<A, R>> mFunc) {
|
||||
String dtoFieldName = func.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(func)).get(dtoFieldName);
|
||||
//获取集合泛型
|
||||
@ -215,7 +215,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
}
|
||||
|
||||
public <A, B> Builder<E, T> association(Class<A> child, KProperty<?> dtoField,
|
||||
MFunc<Builder<A, B>> collection) {
|
||||
MFunction<Builder<A, B>> collection) {
|
||||
return association(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public <A, B> Builder<E, T> association(KProperty<?> dtoField,
|
||||
MFunc<MybatisLabelFree.Builder<B>> collection) {
|
||||
MFunction<MybatisLabelFree.Builder<B>> collection) {
|
||||
String dtoFieldName = dtoField.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(dtoField)).get(dtoFieldName);
|
||||
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
||||
@ -236,7 +236,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public <A, B> Builder<E, T> association(String index, Class<A> child, KProperty<?> dtoField,
|
||||
MFunc<Builder<A, B>> collection) {
|
||||
MFunction<Builder<A, B>> collection) {
|
||||
String dtoFieldName = dtoField.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(dtoField)).get(dtoFieldName);
|
||||
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
||||
|
@ -8,9 +8,9 @@ import com.github.yulichang.toolkit.MPJReflectionKit;
|
||||
import com.github.yulichang.toolkit.TableHelper;
|
||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||
import com.github.yulichang.toolkit.support.FieldCache;
|
||||
import com.github.yulichang.wrapper.interfaces.MFunction;
|
||||
import com.github.yulichang.wrapper.resultmap.IResult;
|
||||
import com.github.yulichang.wrapper.resultmap.Label;
|
||||
import com.github.yulichang.wrapper.resultmap.MFunc;
|
||||
import com.github.yulichang.wrapper.resultmap.ResultList;
|
||||
import com.github.yulichang.wrapper.segments.SelectCache;
|
||||
import kotlin.reflect.KProperty;
|
||||
@ -176,11 +176,11 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> collection(Class<?> entityClass, KProperty<?> func, MFunc<MybatisLabel.Builder<?, ?>> mFunc) {
|
||||
public Builder<T> collection(Class<?> entityClass, KProperty<?> func, MFunction<MybatisLabel.Builder<?, ?>> mFunc) {
|
||||
return collection(null, entityClass, func, mFunc);
|
||||
}
|
||||
|
||||
public Builder<T> collection(KProperty<?> func, MFunc<Builder<?>> mFunc) {
|
||||
public Builder<T> collection(KProperty<?> func, MFunction<Builder<?>> mFunc) {
|
||||
String dtoFieldName = func.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(func)).get(dtoFieldName);
|
||||
//获取集合泛型
|
||||
@ -196,7 +196,7 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
public Builder<T> collection(String prefix,
|
||||
Class<?> entityClass,
|
||||
KProperty<?> func,
|
||||
MFunc<MybatisLabel.Builder<?, ?>> mFunc) {
|
||||
MFunction<MybatisLabel.Builder<?, ?>> mFunc) {
|
||||
String dtoFieldName = func.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(func)).get(dtoFieldName);
|
||||
//获取集合泛型
|
||||
@ -225,7 +225,7 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
}
|
||||
|
||||
public Builder<T> association(Class<?> child, KProperty<?> dtoField,
|
||||
MFunc<MybatisLabel.Builder<?, ?>> collection) {
|
||||
MFunction<MybatisLabel.Builder<?, ?>> collection) {
|
||||
return association(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public Builder<T> association(String index, Class<?> child, KProperty<?> dtoField,
|
||||
MFunc<MybatisLabel.Builder<?, ?>> collection) {
|
||||
MFunction<MybatisLabel.Builder<?, ?>> collection) {
|
||||
String dtoFieldName = dtoField.getName();
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(KtUtils.ref(dtoField)).get(dtoFieldName);
|
||||
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.github.yulichang.toolkit;
|
||||
|
||||
import com.github.yulichang.wrapper.interfaces.DoSomething;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -24,17 +26,17 @@ public class ThrowOptional {
|
||||
|
||||
public void catchDo() {
|
||||
try {
|
||||
this.doSomething.doSomething();
|
||||
this.doSomething.doIt();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public void catchDo(DoSomething doSomething) {
|
||||
try {
|
||||
this.doSomething.doSomething();
|
||||
this.doSomething.doIt();
|
||||
} catch (Throwable ignored) {
|
||||
try {
|
||||
doSomething.doSomething();
|
||||
doSomething.doIt();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -43,15 +45,10 @@ public class ThrowOptional {
|
||||
|
||||
public void catchDo(Consumer<Throwable> consumer) {
|
||||
try {
|
||||
this.doSomething.doSomething();
|
||||
this.doSomething.doIt();
|
||||
} catch (Throwable throwable) {
|
||||
consumer.accept(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DoSomething {
|
||||
void doSomething() throws Throwable;
|
||||
}
|
||||
}
|
||||
|
@ -920,15 +920,6 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
||||
return SerializationUtils.clone(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 做事函数
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface DoSomething {
|
||||
|
||||
void doIt();
|
||||
}
|
||||
|
||||
/* ************************* on语句重载 *************************** */
|
||||
|
||||
@Override
|
||||
|
@ -16,8 +16,8 @@ import java.util.List;
|
||||
* @author yulichang
|
||||
* @since 1.4.4
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public interface Chain<T> {
|
||||
@SuppressWarnings("unused")
|
||||
public interface Chain<T> extends MPJBaseJoin<T> {
|
||||
|
||||
Class<T> getEntityClass();
|
||||
|
||||
@ -29,7 +29,7 @@ public interface Chain<T> {
|
||||
* JoinWrappers.lambda(User.class)<br />
|
||||
*/
|
||||
default Long count() {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinCount((MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinCount(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +40,7 @@ public interface Chain<T> {
|
||||
* JoinWrappers.lambda(User.class)<br />
|
||||
*/
|
||||
default T one() {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinOne(getEntityClass(), (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinOne(getEntityClass(), this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,7 +51,7 @@ public interface Chain<T> {
|
||||
* JoinWrappers.lambda(User.class)<br />
|
||||
*/
|
||||
default <R> R one(Class<R> resultType) {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinOne(resultType, (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinOne(resultType, this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +83,7 @@ public interface Chain<T> {
|
||||
* JoinWrappers.lambda(User.class)<br />
|
||||
*/
|
||||
default List<T> list() {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinList(getEntityClass(), (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinList(getEntityClass(), this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +93,7 @@ public interface Chain<T> {
|
||||
* JoinWrappers.lambda(User.class)<br />
|
||||
*/
|
||||
default <R> List<R> list(Class<R> resultType) {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinList(resultType, (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinList(resultType, this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +103,7 @@ public interface Chain<T> {
|
||||
* JoinWrappers.lambda(User.class)<br />
|
||||
*/
|
||||
default <P extends IPage<T>> P page(P page) {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinPage(page, getEntityClass(), (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinPage(page, getEntityClass(), this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,6 +113,6 @@ public interface Chain<T> {
|
||||
* JoinWrappers.lambda(User.class)<br />
|
||||
*/
|
||||
default <R, P extends IPage<R>> P page(P page, Class<R> resultType) {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinPage(page, resultType, (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.selectJoinPage(page, resultType, this));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.github.yulichang.wrapper.interfaces;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.interfaces.MPJBaseJoin;
|
||||
import com.github.yulichang.toolkit.SqlHelper;
|
||||
|
||||
@ -15,7 +13,7 @@ import com.github.yulichang.toolkit.SqlHelper;
|
||||
* @author yulichang
|
||||
* @since 1.4.10
|
||||
*/
|
||||
public interface DeleteChain<T> {
|
||||
public interface DeleteChain<T> extends MPJBaseJoin<T> {
|
||||
|
||||
Class<T> getEntityClass();
|
||||
|
||||
@ -26,11 +24,8 @@ public interface DeleteChain<T> {
|
||||
* new DeleteJoinWrapper(User.class)<br />
|
||||
* JoinWrappers.delete(User.class)<br />
|
||||
*/
|
||||
@SuppressWarnings({"unused", "unchecked"})
|
||||
@SuppressWarnings("unused")
|
||||
default int deleteJoin() {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> {
|
||||
Assert.isTrue(mapper instanceof MPJBaseMapper, "mapper <%s> is not extends MPJBaseMapper", mapper.getClass().getSimpleName());
|
||||
return ((MPJBaseMapper<T>) mapper).deleteJoin((MPJBaseJoin<T>) this);
|
||||
});
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.deleteJoin(this));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.github.yulichang.wrapper.interfaces;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DoSomething {
|
||||
|
||||
void doIt();
|
||||
}
|
@ -7,7 +7,7 @@ package com.github.yulichang.wrapper.interfaces;
|
||||
* @since 1.1.8
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface WrapperFunction<T> {
|
||||
public interface MFunction<T> {
|
||||
|
||||
T apply(T wrapper);
|
||||
}
|
@ -45,7 +45,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件`
|
||||
*/
|
||||
default <T> Children leftJoin(Class<T> clazz, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children leftJoin(Class<T> clazz, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.LEFT_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default <T, X> Children leftJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children leftJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.LEFT_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default <T> Children leftJoin(Class<T> clazz, String alias, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children leftJoin(Class<T> clazz, String alias, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.LEFT_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default <T, X> Children leftJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children leftJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.LEFT_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -148,14 +148,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T> Children rightJoin(Class<T> clazz, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children rightJoin(Class<T> clazz, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T, X> Children rightJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children rightJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -176,14 +176,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T> Children rightJoin(Class<T> clazz, String alias, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children rightJoin(Class<T> clazz, String alias, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T, X> Children rightJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children rightJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -212,14 +212,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T> Children innerJoin(Class<T> clazz, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children innerJoin(Class<T> clazz, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.INNER_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T, X> Children innerJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children innerJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.INNER_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -241,14 +241,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T> Children innerJoin(Class<T> clazz, String alias, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children innerJoin(Class<T> clazz, String alias, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.INNER_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T, X> Children innerJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children innerJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.INNER_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -283,14 +283,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T> Children fullJoin(Class<T> clazz, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children fullJoin(Class<T> clazz, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.FULL_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T, X> Children fullJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children fullJoin(Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.FULL_JOIN, clazz, left, right, ext);
|
||||
}
|
||||
|
||||
@ -318,14 +318,14 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T> Children fullJoin(Class<T> clazz, String alias, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children fullJoin(Class<T> clazz, String alias, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(Constant.FULL_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default <T, X> Children fullJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children fullJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(Constant.FULL_JOIN, clazz, alias, left, right, ext);
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default <T> Children join(String keyWord, Class<T> clazz, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children join(String keyWord, Class<T> clazz, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(keyWord, clazz, (on, e) -> function.apply(on));
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default <T, X> Children join(String keyWord, Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children join(String keyWord, Class<T> clazz, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(keyWord, clazz, (on, e) -> {
|
||||
on.eq(left, right);
|
||||
ext.apply(e);
|
||||
@ -429,7 +429,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default <T> Children join(String keyWord, Class<T> clazz, String alias, WrapperFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
default <T> Children join(String keyWord, Class<T> clazz, String alias, MFunction<JoinAbstractLambdaWrapper<Entity, ?>> function) {
|
||||
return join(keyWord, clazz, alias, (on, e) -> function.apply(on));
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param left 条件
|
||||
* @param right 条件
|
||||
*/
|
||||
default <T, X> Children join(String keyWord, Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<Children> ext) {
|
||||
default <T, X> Children join(String keyWord, Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, MFunction<Children> ext) {
|
||||
return join(keyWord, clazz, alias, (on, e) -> {
|
||||
on.eq(left, right);
|
||||
ext.apply(e);
|
||||
|
@ -7,7 +7,6 @@ import com.github.yulichang.toolkit.LambdaUtils;
|
||||
import com.github.yulichang.toolkit.MPJReflectionKit;
|
||||
import com.github.yulichang.toolkit.support.FieldCache;
|
||||
import com.github.yulichang.wrapper.resultmap.Label;
|
||||
import com.github.yulichang.wrapper.resultmap.MFunc;
|
||||
import com.github.yulichang.wrapper.resultmap.MybatisLabel;
|
||||
import com.github.yulichang.wrapper.resultmap.MybatisLabelFree;
|
||||
|
||||
@ -102,12 +101,12 @@ public interface QueryLabel<Children> {
|
||||
*/
|
||||
default <S, C, Z, F extends Collection<Z>> Children selectCollection(Class<C> child,
|
||||
SFunction<S, F> dtoField,
|
||||
MFunc<MybatisLabel.Builder<C, Z>> collection) {
|
||||
MFunction<MybatisLabel.Builder<C, Z>> collection) {
|
||||
return selectCollection(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
default <S, Z, F extends Collection<Z>> Children selectCollection(SFunction<S, F> dtoField,
|
||||
MFunc<MybatisLabelFree.Builder<Z>> collection) {
|
||||
MFunction<MybatisLabelFree.Builder<Z>> collection) {
|
||||
//自由映射必须存在泛型Z
|
||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||
Class<S> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||
@ -124,7 +123,7 @@ public interface QueryLabel<Children> {
|
||||
default <S, C, Z, F extends Collection<Z>> Children selectCollection(String prefix,
|
||||
Class<C> child,
|
||||
SFunction<S, F> dtoField,
|
||||
MFunc<MybatisLabel.Builder<C, Z>> collection) {
|
||||
MFunction<MybatisLabel.Builder<C, Z>> collection) {
|
||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||
Class<S> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
@ -165,12 +164,12 @@ public interface QueryLabel<Children> {
|
||||
* @since 1.3.0
|
||||
*/
|
||||
default <S, C, F> Children selectAssociation(Class<C> child, SFunction<S, F> dtoField,
|
||||
MFunc<MybatisLabel.Builder<C, F>> collection) {
|
||||
MFunction<MybatisLabel.Builder<C, F>> collection) {
|
||||
return selectAssociation(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
default <S, C, F> Children selectAssociation(SFunction<S, F> dtoField,
|
||||
MFunc<MybatisLabelFree.Builder<F>> collection) {
|
||||
MFunction<MybatisLabelFree.Builder<F>> collection) {
|
||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||
Class<S> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
@ -182,7 +181,7 @@ public interface QueryLabel<Children> {
|
||||
}
|
||||
|
||||
default <S, C, F> Children selectAssociation(String prefix, Class<C> child, SFunction<S, F> dtoField,
|
||||
MFunc<MybatisLabel.Builder<C, F>> collection) {
|
||||
MFunction<MybatisLabel.Builder<C, F>> collection) {
|
||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||
Class<S> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
|
@ -13,8 +13,8 @@ import com.github.yulichang.toolkit.SqlHelper;
|
||||
* @author yulichang
|
||||
* @since 1.4.10
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public interface UpdateChain<T> {
|
||||
@SuppressWarnings("unused")
|
||||
public interface UpdateChain<T> extends MPJBaseJoin<T> {
|
||||
|
||||
Class<T> getEntityClass();
|
||||
|
||||
@ -26,7 +26,7 @@ public interface UpdateChain<T> {
|
||||
* JoinWrappers.update(User.class)<br />
|
||||
*/
|
||||
default int update() {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoin(null, (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoin(null, this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ public interface UpdateChain<T> {
|
||||
* JoinWrappers.update(User.class)<br />
|
||||
*/
|
||||
default int update(T entity) {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoin(entity, (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoin(entity, this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,7 +48,7 @@ public interface UpdateChain<T> {
|
||||
* JoinWrappers.update(User.class)<br />
|
||||
*/
|
||||
default int updateAndNull() {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoinAndNull(null, (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoinAndNull(null, this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,6 +59,6 @@ public interface UpdateChain<T> {
|
||||
* JoinWrappers.update(User.class)<br />
|
||||
*/
|
||||
default int updateAndNull(T entity) {
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoinAndNull(entity, (MPJBaseJoin<T>) this));
|
||||
return SqlHelper.exec(getEntityClass(), mapper -> mapper.updateJoinAndNull(entity, this));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
package com.github.yulichang.wrapper.resultmap;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MFunc<T> {
|
||||
|
||||
T apply(T t);
|
||||
}
|
@ -9,6 +9,7 @@ import com.github.yulichang.toolkit.MPJReflectionKit;
|
||||
import com.github.yulichang.toolkit.TableHelper;
|
||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||
import com.github.yulichang.toolkit.support.FieldCache;
|
||||
import com.github.yulichang.wrapper.interfaces.MFunction;
|
||||
import com.github.yulichang.wrapper.segments.SelectCache;
|
||||
import lombok.Getter;
|
||||
|
||||
@ -158,7 +159,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public <A, R, B extends Collection<R>> Builder<E, T> collection(Class<A> entityClass, SFunction<T, B> func, MFunc<Builder<A, R>> mFunc) {
|
||||
public <A, R, B extends Collection<R>> Builder<E, T> collection(Class<A> entityClass, SFunction<T, B> func, MFunction<Builder<A, R>> mFunc) {
|
||||
return collection(null, entityClass, func, mFunc);
|
||||
}
|
||||
|
||||
@ -166,7 +167,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public <A, R, B extends Collection<R>> Builder<E, T> collection(SFunction<T, B> func,
|
||||
MFunc<MybatisLabelFree.Builder<R>> mFunc) {
|
||||
MFunction<MybatisLabelFree.Builder<R>> mFunc) {
|
||||
String dtoFieldName = LambdaUtils.getName(func);
|
||||
Class<T> dtoClass = LambdaUtils.getEntityClass(func);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
@ -184,7 +185,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
public <A, R, B extends Collection<R>> Builder<E, T> collection(String prefix,
|
||||
Class<A> entityClass,
|
||||
SFunction<T, B> func,
|
||||
MFunc<Builder<A, R>> mFunc) {
|
||||
MFunction<Builder<A, R>> mFunc) {
|
||||
String dtoFieldName = LambdaUtils.getName(func);
|
||||
Class<T> dtoClass = LambdaUtils.getEntityClass(func);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
@ -216,7 +217,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
}
|
||||
|
||||
public <A, B> Builder<E, T> association(Class<A> child, SFunction<T, B> dtoField,
|
||||
MFunc<MybatisLabel.Builder<A, B>> collection) {
|
||||
MFunction<MybatisLabel.Builder<A, B>> collection) {
|
||||
return association(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
@ -224,7 +225,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public <A, B> Builder<E, T> association(SFunction<T, B> dtoField,
|
||||
MFunc<MybatisLabelFree.Builder<B>> collection) {
|
||||
MFunction<MybatisLabelFree.Builder<B>> collection) {
|
||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||
Class<T> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
@ -238,7 +239,7 @@ public class MybatisLabel<E, T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public <A, B> Builder<E, T> association(String index, Class<A> child, SFunction<T, B> dtoField,
|
||||
MFunc<MybatisLabel.Builder<A, B>> collection) {
|
||||
MFunction<MybatisLabel.Builder<A, B>> collection) {
|
||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||
Class<T> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
|
@ -9,6 +9,7 @@ import com.github.yulichang.toolkit.MPJReflectionKit;
|
||||
import com.github.yulichang.toolkit.TableHelper;
|
||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||
import com.github.yulichang.toolkit.support.FieldCache;
|
||||
import com.github.yulichang.wrapper.interfaces.MFunction;
|
||||
import com.github.yulichang.wrapper.segments.SelectCache;
|
||||
import lombok.Getter;
|
||||
|
||||
@ -174,12 +175,12 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public <A, R, B extends Collection<R>> Builder<T> collection(Class<A> entityClass, SFunction<T, B> func, MFunc<MybatisLabel.Builder<A, R>> mFunc) {
|
||||
public <A, R, B extends Collection<R>> Builder<T> collection(Class<A> entityClass, SFunction<T, B> func, MFunction<MybatisLabel.Builder<A, R>> mFunc) {
|
||||
return collection(null, entityClass, func, mFunc);
|
||||
}
|
||||
|
||||
public <A, R, B extends Collection<R>> Builder<T> collection(SFunction<T, B> func,
|
||||
MFunc<MybatisLabelFree.Builder<R>> mFunc) {
|
||||
MFunction<MybatisLabelFree.Builder<R>> mFunc) {
|
||||
String dtoFieldName = LambdaUtils.getName(func);
|
||||
Class<T> dtoClass = LambdaUtils.getEntityClass(func);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
@ -197,7 +198,7 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
public <A, R, B extends Collection<R>> Builder<T> collection(String prefix,
|
||||
Class<A> entityClass,
|
||||
SFunction<T, B> func,
|
||||
MFunc<MybatisLabel.Builder<A, R>> mFunc) {
|
||||
MFunction<MybatisLabel.Builder<A, R>> mFunc) {
|
||||
String dtoFieldName = LambdaUtils.getName(func);
|
||||
Class<T> dtoClass = LambdaUtils.getEntityClass(func);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
@ -229,7 +230,7 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
}
|
||||
|
||||
public <A, B> Builder<T> association(Class<A> child, SFunction<T, B> dtoField,
|
||||
MFunc<MybatisLabel.Builder<A, B>> collection) {
|
||||
MFunction<MybatisLabel.Builder<A, B>> collection) {
|
||||
return association(null, child, dtoField, collection);
|
||||
}
|
||||
|
||||
@ -237,7 +238,7 @@ public class MybatisLabelFree<T> implements Label<T> {
|
||||
* 嵌套
|
||||
*/
|
||||
public <A, B> Builder<T> association(String index, Class<A> child, SFunction<T, B> dtoField,
|
||||
MFunc<MybatisLabel.Builder<A, B>> collection) {
|
||||
MFunction<MybatisLabel.Builder<A, B>> collection) {
|
||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||
Class<T> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||
FieldCache field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user