优化 LambdaQueryWrapperX 的 inIfPresent 判空逻辑

pull/40/MERGE
YunaiV 2023-07-25 20:58:36 +08:00
parent 85d55d1af5
commit c22cf007d1
1 changed files with 3 additions and 3 deletions

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.framework.mybatis.core.query; package cn.iocoder.yudao.framework.mybatis.core.query;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -26,14 +26,14 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> {
} }
public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Collection<?> values) { public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Collection<?> values) {
if (!CollectionUtils.isEmpty(values)) { if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) {
return (LambdaQueryWrapperX<T>) super.in(column, values); return (LambdaQueryWrapperX<T>) super.in(column, values);
} }
return this; return this;
} }
public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Object... values) { public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Object... values) {
if (!ArrayUtil.isEmpty(values)) { if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) {
return (LambdaQueryWrapperX<T>) super.in(column, values); return (LambdaQueryWrapperX<T>) super.in(column, values);
} }
return this; return this;