From fe8d300e25f82b63a1fc6dac73b76069ea750b2a Mon Sep 17 00:00:00 2001 From: cc <54989627@QQ.COM> Date: Wed, 5 Jun 2024 16:00:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=81=92=E7=9C=9F=E5=92=8C?= =?UTF-8?q?=E6=81=92=E5=81=87=E6=93=8D=E4=BD=9C=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bean-searcher/pom.xml | 2 +- .../src/main/java/cn/zhxu/bs/FieldOpPool.java | 3 + .../src/main/java/cn/zhxu/bs/FieldOps.java | 218 ++++++++++-------- .../java/cn/zhxu/bs/operator/AlwaysFalse.java | 42 ++++ .../java/cn/zhxu/bs/operator/AlwaysTrue.java | 42 ++++ 5 files changed, 206 insertions(+), 101 deletions(-) create mode 100644 bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysFalse.java create mode 100644 bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysTrue.java diff --git a/bean-searcher/pom.xml b/bean-searcher/pom.xml index 6ba049f8..20b20728 100644 --- a/bean-searcher/pom.xml +++ b/bean-searcher/pom.xml @@ -11,7 +11,7 @@ cn.zhxu bean-searcher-parent - 4.2.9 + 4.2.10 diff --git a/bean-searcher/src/main/java/cn/zhxu/bs/FieldOpPool.java b/bean-searcher/src/main/java/cn/zhxu/bs/FieldOpPool.java index 147ef9b5..6ca679ff 100644 --- a/bean-searcher/src/main/java/cn/zhxu/bs/FieldOpPool.java +++ b/bean-searcher/src/main/java/cn/zhxu/bs/FieldOpPool.java @@ -46,6 +46,9 @@ public class FieldOpPool extends DialectWrapper { checkAdd(FieldOps.NotNull); checkAdd(FieldOps.Empty); checkAdd(FieldOps.NotEmpty); + checkAdd(FieldOps.AlwaysTrue); + checkAdd(FieldOps.AlwaysFalse); + } diff --git a/bean-searcher/src/main/java/cn/zhxu/bs/FieldOps.java b/bean-searcher/src/main/java/cn/zhxu/bs/FieldOps.java index 54af0a57..7d5a7ad5 100644 --- a/bean-searcher/src/main/java/cn/zhxu/bs/FieldOps.java +++ b/bean-searcher/src/main/java/cn/zhxu/bs/FieldOps.java @@ -4,109 +4,127 @@ import cn.zhxu.bs.operator.*; /** * 过滤运算符 + * * @author Troy.Zhou @ 2017-03-20 */ public class FieldOps { - /** - * 等于 - */ - public static final Equal Equal = new Equal(); - - /** - * 不等于 - */ - public static final NotEqual NotEqual = new NotEqual(); - - /** - * 大于等于 - */ - public static final GreaterEqual GreaterEqual = new GreaterEqual(); - - /** - * 大于 - */ - public static final GreaterThan GreaterThan = new GreaterThan(); - - /** - * 小于等于 - */ - public static final LessEqual LessEqual = new LessEqual(); - - /** - * 小于 - */ - public static final LessThan LessThan = new LessThan(); - - /** - * 为 null - */ - public static final IsNull IsNull = new IsNull(); - - /** - * 不为 null - */ - public static final NotNull NotNull = new NotNull(); - - /** - * 为空 - */ - public static final Empty Empty = new Empty(); - - /** - * 不为空 - */ - public static final NotEmpty NotEmpty = new NotEmpty(); - - /** - * 包含 - * like '%xxx%' - */ - public static final Contain Contain = new Contain(); - - /** - * 以 .. 开始 - * like 'xxx%' - */ - public static final StartWith StartWith = new StartWith(); - - /** - * 以 .. 结束 - * like '%xxx' - */ - public static final EndWith EndWith = new EndWith(); - - /** - * like {v1} or like {v1} - */ - public static final OrLike OrLike = new OrLike(); - - /** - * not like {v} - */ - public static final NotLike NotLike = new NotLike(); - - /** - * 在 .. 和 .. 之间 - */ - public static final Between Between = new Between(); - - /** - * 不在 .. 和 .. 之间 - */ - public static final NotBetween NotBetween = new NotBetween(); - - /** - * 在列表中 - * in (...) - */ - public static final InList InList = new InList(); - - /** - * 不在某个集合内 - * not in - * @since v3.3 - */ - public static final NotIn NotIn = new NotIn(); + /** + * 等于 + */ + public static final Equal Equal = new Equal(); + + /** + * 不等于 + */ + public static final NotEqual NotEqual = new NotEqual(); + + /** + * 大于等于 + */ + public static final GreaterEqual GreaterEqual = new GreaterEqual(); + + /** + * 大于 + */ + public static final GreaterThan GreaterThan = new GreaterThan(); + + /** + * 小于等于 + */ + public static final LessEqual LessEqual = new LessEqual(); + + /** + * 小于 + */ + public static final LessThan LessThan = new LessThan(); + + /** + * 为 null + */ + public static final IsNull IsNull = new IsNull(); + + /** + * 不为 null + */ + public static final NotNull NotNull = new NotNull(); + + /** + * 为空 + */ + public static final Empty Empty = new Empty(); + + /** + * 不为空 + */ + public static final NotEmpty NotEmpty = new NotEmpty(); + + /** + * 包含 + * like '%xxx%' + */ + public static final Contain Contain = new Contain(); + + /** + * 以 .. 开始 + * like 'xxx%' + */ + public static final StartWith StartWith = new StartWith(); + + /** + * 以 .. 结束 + * like '%xxx' + */ + public static final EndWith EndWith = new EndWith(); + + /** + * like {v1} or like {v1} + */ + public static final OrLike OrLike = new OrLike(); + + /** + * not like {v} + */ + public static final NotLike NotLike = new NotLike(); + + /** + * 在 .. 和 .. 之间 + */ + public static final Between Between = new Between(); + + /** + * 不在 .. 和 .. 之间 + */ + public static final NotBetween NotBetween = new NotBetween(); + + /** + * 在列表中 + * in (...) + */ + public static final InList InList = new InList(); + + /** + * 不在某个集合内 + * not in + * + * @since v3.3 + */ + public static final NotIn NotIn = new NotIn(); + + /** + * 恒真运算符 + * always true + * + * @since v4.2.10 + */ + public static final AlwaysTrue AlwaysTrue = new AlwaysTrue(); + + /** + * 恒假运算符 + * always true + * + * @since v4.2.10 + */ + public static final AlwaysFalse AlwaysFalse = new AlwaysFalse(); } \ No newline at end of file diff --git a/bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysFalse.java b/bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysFalse.java new file mode 100644 index 00000000..85f15650 --- /dev/null +++ b/bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysFalse.java @@ -0,0 +1,42 @@ +package cn.zhxu.bs.operator; + +import cn.zhxu.bs.FieldOp; +import cn.zhxu.bs.dialect.DialectWrapper; + +import java.util.Collections; +import java.util.List; + +/** + * 恒假运算符,用于忽略字段参数值,生成0条件 + * + * @author Corey @ 2024-06-13 + * @since v4.2.10 + */ +public class AlwaysFalse extends DialectWrapper implements FieldOp { + + + @Override + public String name () { + + return "AlwaysFalse"; + } + + @Override + public boolean isNamed ( String name ) { + + return "af".equals( name ) || "AlwaysFalse".equals( name ); + } + + @Override + public boolean lonely () { + + return true; + } + + @Override + public List< Object > operate ( StringBuilder sqlBuilder, OpPara opPara ) { + + sqlBuilder.append( "0" ); + return Collections.emptyList(); + } +} diff --git a/bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysTrue.java b/bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysTrue.java new file mode 100644 index 00000000..10b0bc24 --- /dev/null +++ b/bean-searcher/src/main/java/cn/zhxu/bs/operator/AlwaysTrue.java @@ -0,0 +1,42 @@ +package cn.zhxu.bs.operator; + +import cn.zhxu.bs.FieldOp; +import cn.zhxu.bs.dialect.DialectWrapper; + +import java.util.Collections; +import java.util.List; + +/** + * 恒真运算符,用于忽略字段参数值,生成1条件 + * + * @author Corey @ 2024-06-13 + * @since v4.2.0 + */ +public class AlwaysTrue extends DialectWrapper implements FieldOp { + + + @Override + public String name () { + + return "AlwaysTrue"; + } + + @Override + public boolean isNamed ( String name ) { + + return "at".equals( name ) || "AlwaysTrue".equals( name ); + } + + @Override + public boolean lonely () { + + return true; + } + + @Override + public List< Object > operate ( StringBuilder sqlBuilder, OpPara opPara ) { + + sqlBuilder.append( "1" ); + return Collections.emptyList(); + } +} -- Gitee