().eq(field, value));
+ }
+
+}
diff --git a/framework/spring-boot-starter-mybatis/src/main/java/cd/casic/framework/mybatis/core/query/LambdaQueryWrapperX.java b/framework/spring-boot-starter-mybatis/src/main/java/cd/casic/framework/mybatis/core/query/LambdaQueryWrapperX.java
new file mode 100644
index 0000000..26d0771
--- /dev/null
+++ b/framework/spring-boot-starter-mybatis/src/main/java/cd/casic/framework/mybatis/core/query/LambdaQueryWrapperX.java
@@ -0,0 +1,135 @@
+package cd.casic.framework.mybatis.core.query;
+
+import cd.casic.framework.commons.util.collection.ArrayUtils;
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
+import org.springframework.util.StringUtils;
+
+import java.util.Collection;
+
+/**
+ * 拓展 MyBatis Plus QueryWrapper 类,主要增加如下功能:
+ *
+ * 1. 拼接条件的方法,增加 xxxIfPresent 方法,用于判断值不存在的时候,不要拼接到条件中。
+ *
+ * @param 数据类型
+ */
+public class LambdaQueryWrapperX extends LambdaQueryWrapper {
+
+ public LambdaQueryWrapperX likeIfPresent(SFunction column, String val) {
+ if (StringUtils.hasText(val)) {
+ return (LambdaQueryWrapperX) super.like(column, val);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX inIfPresent(SFunction column, Collection> values) {
+ if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) {
+ return (LambdaQueryWrapperX) super.in(column, values);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX inIfPresent(SFunction column, Object... values) {
+ if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) {
+ return (LambdaQueryWrapperX) super.in(column, values);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX eqIfPresent(SFunction column, Object val) {
+ if (ObjectUtil.isNotEmpty(val)) {
+ return (LambdaQueryWrapperX) super.eq(column, val);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX neIfPresent(SFunction column, Object val) {
+ if (ObjectUtil.isNotEmpty(val)) {
+ return (LambdaQueryWrapperX) super.ne(column, val);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX gtIfPresent(SFunction column, Object val) {
+ if (val != null) {
+ return (LambdaQueryWrapperX) super.gt(column, val);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX geIfPresent(SFunction column, Object val) {
+ if (val != null) {
+ return (LambdaQueryWrapperX) super.ge(column, val);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX ltIfPresent(SFunction column, Object val) {
+ if (val != null) {
+ return (LambdaQueryWrapperX) super.lt(column, val);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX leIfPresent(SFunction column, Object val) {
+ if (val != null) {
+ return (LambdaQueryWrapperX) super.le(column, val);
+ }
+ return this;
+ }
+
+ public LambdaQueryWrapperX betweenIfPresent(SFunction column, Object val1, Object val2) {
+ if (val1 != null && val2 != null) {
+ return (LambdaQueryWrapperX) super.between(column, val1, val2);
+ }
+ if (val1 != null) {
+ return (LambdaQueryWrapperX