mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
兼容各版本MP
This commit is contained in:
parent
7efad696da
commit
4dd46bb7e6
@ -474,11 +474,11 @@ public interface MPJDeepMapper<T> extends BaseMapper<T> {
|
|||||||
if (fieldInfo.isMappingEntity()) {
|
if (fieldInfo.isMappingEntity()) {
|
||||||
if (fieldInfo.isFieldIsMap()) {
|
if (fieldInfo.isFieldIsMap()) {
|
||||||
list = ((List<Map<String, Object>>) joinList).stream().filter(j ->
|
list = ((List<Map<String, Object>>) joinList).stream().filter(j ->
|
||||||
j.get(fieldInfo.getJoinMapKey()).equals(t.get(fieldInfo.getThisMapKey())))
|
j.get(fieldInfo.getJoinMapKey()).equals(t.get(fieldInfo.getThisMapKey())))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
list = joinList.stream().filter(j ->
|
list = joinList.stream().filter(j ->
|
||||||
fieldInfo.joinFieldGet(j).equals(t.get(fieldInfo.getThisMapKey())))
|
fieldInfo.joinFieldGet(j).equals(t.get(fieldInfo.getThisMapKey())))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -501,13 +501,23 @@ public interface MPJDeepMapper<T> extends BaseMapper<T> {
|
|||||||
infoWrapper.getConditionList().forEach(c -> wrapper.addCondition(true, c.getColumn(),
|
infoWrapper.getConditionList().forEach(c -> wrapper.addCondition(true, c.getColumn(),
|
||||||
c.getKeyword(), c.getVal()));
|
c.getKeyword(), c.getVal()));
|
||||||
}
|
}
|
||||||
wrapper.eq(SqlKeyword.EQ == keyword, column, val)
|
wrapper.eq(SqlKeyword.EQ == keyword, column, val);
|
||||||
.first(infoWrapper.isHasFirst(), infoWrapper.getFirst())
|
//此处不用链式调用,提高效率
|
||||||
.orderByAsc(infoWrapper.isHasOrderByAsc(), infoWrapper.getOrderByAsc())
|
if (infoWrapper.isHasFirst()) {
|
||||||
.orderByDesc(infoWrapper.isHasOrderByDesc(), infoWrapper.getOrderByDesc())
|
wrapper.first(infoWrapper.getFirst());
|
||||||
.last(infoWrapper.isHasLast(), infoWrapper.getLast());
|
}
|
||||||
|
if (infoWrapper.isHasOrderByAsc()) {
|
||||||
|
//mybatis plus 3.4.3 之后支持数组,但之前版本仅支持可变参数,为了兼容,多个循环处理
|
||||||
|
infoWrapper.getOrderByAsc().forEach(wrapper::orderByAsc);
|
||||||
|
}
|
||||||
|
if (infoWrapper.isHasOrderByDesc()) {
|
||||||
|
//mybatis plus 3.4.3 之后支持数组,但之前版本仅支持可变参数,为了兼容,多个循环处理
|
||||||
|
infoWrapper.getOrderByAsc().forEach(wrapper::orderByDesc);
|
||||||
|
}
|
||||||
|
if (infoWrapper.isHasLast()) {
|
||||||
|
wrapper.last(infoWrapper.getLast());
|
||||||
|
}
|
||||||
if (SqlKeyword.IN == keyword) {
|
if (SqlKeyword.IN == keyword) {
|
||||||
//由于Java发放调用机制 无法使用链式
|
|
||||||
wrapper.in(column, (List<?>) val);
|
wrapper.in(column, (List<?>) val);
|
||||||
}
|
}
|
||||||
if (infoWrapper.isHasSelect()) {
|
if (infoWrapper.isHasSelect()) {
|
||||||
|
@ -33,7 +33,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author yulichang
|
* @author yulichang
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings({"DeprecatedIsStillUsed", "unused"})
|
@SuppressWarnings("unused")
|
||||||
public class MPJLambdaQueryWrapper<T> extends AbstractLambdaWrapper<T, MPJLambdaQueryWrapper<T>>
|
public class MPJLambdaQueryWrapper<T> extends AbstractLambdaWrapper<T, MPJLambdaQueryWrapper<T>>
|
||||||
implements Query<MPJLambdaQueryWrapper<T>, T, SFunction<T, ?>>, MPJJoin<MPJLambdaQueryWrapper<T>> {
|
implements Query<MPJLambdaQueryWrapper<T>, T, SFunction<T, ?>>, MPJJoin<MPJLambdaQueryWrapper<T>> {
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ public class MPJLambdaQueryWrapper<T> extends AbstractLambdaWrapper<T, MPJLambda
|
|||||||
public final MPJLambdaQueryWrapper<T> selectIgnore(SFunction<T, ?>... columns) {
|
public final MPJLambdaQueryWrapper<T> selectIgnore(SFunction<T, ?>... columns) {
|
||||||
if (ArrayUtils.isNotEmpty(columns)) {
|
if (ArrayUtils.isNotEmpty(columns)) {
|
||||||
for (SFunction<T, ?> s : columns) {
|
for (SFunction<T, ?> s : columns) {
|
||||||
ignoreColumns.add(Constant.TABLE_ALIAS + StringPool.DOT + getColumnCache(s).getColumn());
|
ignoreColumns.add(Constant.TABLE_ALIAS + StringPool.DOT + columnToString(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user