24282 1 year ago
parent
commit
2315e16b5b

+ 85 - 1
my-test/src/main/java/org/example/join/model/query/column/AbstractQueryColumn.java

@@ -89,38 +89,74 @@ public abstract class AbstractQueryColumn implements IQueryColumn {
         return new QueryCondition(this, SqlConstant.EQ, obj);
     }
 
+    public QueryCondition eq(boolean b, Object obj) {
+        return b ? eq(obj) : skip();
+    }
+
     public QueryCondition ne(Object obj) {
         return new QueryCondition(this, SqlConstant.NE, obj);
     }
 
+    public QueryCondition ne(boolean b, Object obj) {
+        return b ? ne(obj) : skip();
+    }
+
     public QueryCondition gt(Object obj) {
         return new QueryCondition(this, SqlConstant.GT, obj);
     }
 
+    public QueryCondition gt(boolean b, Object obj) {
+        return b ? gt(obj) : skip();
+    }
+
     public QueryCondition lt(Object obj) {
         return new QueryCondition(this, SqlConstant.LT, obj);
     }
 
+    public QueryCondition lt(boolean b, Object obj) {
+        return b ? lt(obj) : skip();
+    }
+
     public QueryCondition ge(Object obj) {
         return new QueryCondition(this, SqlConstant.GE, obj);
     }
 
+    public QueryCondition ge(boolean b, Object obj) {
+        return b ? ge(obj) : skip();
+    }
+
     public QueryCondition le(Object obj) {
         return new QueryCondition(this, SqlConstant.LE, obj);
     }
 
+    public QueryCondition le(boolean b, Object obj) {
+        return b ? le(obj) : skip();
+    }
+
     public QueryCondition like(Object obj) {
         return new QueryCondition(this, SqlConstant.LIKE, obj);
     }
 
+    public QueryCondition like(boolean b, Object obj) {
+        return b ? like(obj) : skip();
+    }
+
     public QueryCondition notLike(Object obj) {
         return new QueryCondition(this, SqlConstant.NOT_LIKE, obj);
     }
 
+    public QueryCondition notLike(boolean b, Object obj) {
+        return b ? notLike(obj) : skip();
+    }
+
     public QueryCondition in(Collection<?> coll) {
         return new QueryCondition(this, SqlConstant.IN, coll);
     }
 
+    public QueryCondition in(boolean b, Collection<?> coll) {
+        return b ? in(coll) : skip();
+    }
+
     public QueryCondition in(Object... objs) {
         if (ObjectUtil.isEmpty(objs)) {
             return new QueryCondition(this, SqlConstant.IN, null);
@@ -128,10 +164,18 @@ public abstract class AbstractQueryColumn implements IQueryColumn {
         return new QueryCondition(this, SqlConstant.IN, ListUtil.toList(objs));
     }
 
+    public QueryCondition in(boolean b, Object... objs) {
+        return b ? in(objs) : skip();
+    }
+
     public QueryCondition notIn(Collection<?> coll) {
         return new QueryCondition(this, SqlConstant.NOT_IN, coll);
     }
 
+    public QueryCondition notIn(boolean b, Collection<?> coll) {
+        return b ? notIn(coll) : skip();
+    }
+
     public QueryCondition notIn(Object... objs) {
         if (ObjectUtil.isEmpty(objs)) {
             return new QueryCondition(this, SqlConstant.NOT_IN, null);
@@ -139,6 +183,10 @@ public abstract class AbstractQueryColumn implements IQueryColumn {
         return new QueryCondition(this, SqlConstant.NOT_IN, ListUtil.toList(objs));
     }
 
+    public QueryCondition notIn(boolean b, Object... objs) {
+        return b ? notIn(objs) : skip();
+    }
+
     public QueryCondition between(Object obj1, Object obj2) {
         if (ObjectUtil.isAllNotEmpty(obj1, obj2)) {
             return new QueryCondition(this, SqlConstant.BETWEEN, new Object[]{obj1, obj2});
@@ -146,6 +194,10 @@ public abstract class AbstractQueryColumn implements IQueryColumn {
         return new QueryCondition(this, SqlConstant.BETWEEN, null);
     }
 
+    public QueryCondition between(boolean b, Object obj1, Object obj2) {
+        return b ? between(obj1, obj2) : skip();
+    }
+
     public QueryCondition notBetween(Object obj1, Object obj2) {
         if (ObjectUtil.isAllNotEmpty(obj1, obj2)) {
             return new QueryCondition(this, SqlConstant.NOT_BETWEEN, new Object[]{obj1, obj2});
@@ -153,28 +205,60 @@ public abstract class AbstractQueryColumn implements IQueryColumn {
         return new QueryCondition(this, SqlConstant.NOT_BETWEEN, null);
     }
 
+    public QueryCondition notBetween(boolean b, Object obj1, Object obj2) {
+        return b ? notBetween(obj1, obj2) : skip();
+    }
+
     public QueryCondition likeLeft(Object obj) {
         return new QueryCondition(this, SqlConstant.LIKE_LEFT, obj);
     }
 
+    public QueryCondition likeLeft(boolean b, Object obj) {
+        return b ? likeLeft(obj) : skip();
+    }
+
     public QueryCondition notLikeLeft(Object obj) {
         return new QueryCondition(this, SqlConstant.NOT_LIKE_LEFT, obj);
     }
 
+    public QueryCondition notLikeLeft(boolean b, Object obj) {
+        return b ? notLikeLeft(obj) : skip();
+    }
+
     public QueryCondition likeRight(Object obj) {
         return new QueryCondition(this, SqlConstant.LIKE_RIGHT, obj);
     }
 
+    public QueryCondition likeRight(boolean b, Object obj) {
+        return b ? likeRight(obj) : skip();
+    }
+
     public QueryCondition notLikeRight(Object obj) {
         return new QueryCondition(this, SqlConstant.NOT_LIKE_RIGHT, obj);
     }
 
+    public QueryCondition notLikeRight(boolean b, Object obj) {
+        return b ? notLikeRight(obj) : skip();
+    }
+
     public QueryCondition isNull() {
         return new QueryCondition(this, SqlConstant.IS_NULL, SqlConstant.IS_NULL);
     }
 
+    public QueryCondition isNull(boolean b) {
+        return b ? isNull() : skip();
+    }
+
     public QueryCondition isNotNull() {
-        return new QueryCondition(this, SqlConstant.IS_NOT_NULL, SqlConstant.IS_NULL);
+        return new QueryCondition(this, SqlConstant.IS_NOT_NULL, SqlConstant.IS_NOT_NULL);
+    }
+
+    public QueryCondition isNotNull(boolean b) {
+        return b ? isNotNull() : skip();
+    }
+
+    private QueryCondition skip() {
+        return new QueryCondition(this, StringPool.EMPTY, null);
     }
 
     private AbstractQueryColumn compute(String symbol, Object obj) {