File tree Expand file tree Collapse file tree
zoom-mybatis-ext/src/main/java/com/hb0730/zoom/mybatis/query Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import com .hb0730 .zoom .mybatis .query .core .impl .LikeQueryHandler ;
2323import com .hb0730 .zoom .mybatis .query .core .impl .LikeRightQueryHandler ;
2424import com .hb0730 .zoom .mybatis .query .core .impl .OrEqualsPredicateHandler ;
25+ import com .hb0730 .zoom .mybatis .query .core .impl .OrLikePredicateHandler ;
2526import com .hb0730 .zoom .mybatis .query .doamin .PageRequest ;
2627import org .springframework .beans .BeanUtils ;
2728
@@ -57,6 +58,7 @@ public class QueryHelper {
5758 register (new InQueryHandler ());
5859 register (new OrEqualsPredicateHandler ());
5960 register (new BetweenQueryHandler ());
61+ register (new OrLikePredicateHandler ());
6062 }
6163
6264 /**
Original file line number Diff line number Diff line change 1+ package com .hb0730 .zoom .mybatis .query .annotation ;
2+
3+ import java .lang .annotation .Documented ;
4+ import java .lang .annotation .ElementType ;
5+ import java .lang .annotation .Retention ;
6+ import java .lang .annotation .RetentionPolicy ;
7+ import java .lang .annotation .Target ;
8+
9+ /**
10+ * 用于“或模糊匹配某个元素”({@code OR field like ?})场景的注解.
11+ *
12+ * @author <a href="mailto:huangbing0730@gmail">hb0730</a>
13+ * @date 2025/1/8
14+ */
15+ @ Documented
16+ @ Target (ElementType .FIELD )
17+ @ Retention (RetentionPolicy .RUNTIME )
18+ public @interface OrLike {
19+
20+ /**
21+ * 注解的实体字段属性名称/字段column名称,默认为空或空字符串时将使用属性名称.
22+ *
23+ * @return 值
24+ */
25+ String value () default "" ;
26+
27+ /**
28+ * 是否使用驼峰命名,默认为 {@code true}.
29+ *
30+ * @return 值
31+ */
32+ boolean underCamel () default true ;
33+
34+ /**
35+ * 是否添加{@code is_}前缀,只针对Boolean类型有效,默认为 {@code false}.
36+ */
37+ boolean isPrefix () default false ;
38+ }
Original file line number Diff line number Diff line change 1+ package com .hb0730 .zoom .mybatis .query .core .impl ;
2+
3+ import com .baomidou .mybatisplus .core .conditions .query .QueryWrapper ;
4+ import com .hb0730 .zoom .mybatis .query .core .AbstractQueryHandler ;
5+ import jakarta .annotation .Nonnull ;
6+
7+ import java .lang .annotation .Annotation ;
8+
9+ /**
10+ * @author <a href="mailto:huangbing0730@gmail">hb0730</a>
11+ * @date 2025/1/8
12+ */
13+ public class OrLikePredicateHandler extends AbstractQueryHandler {
14+
15+
16+ @ Override
17+ public Class <? extends Annotation > getAnnotation () {
18+ return com .hb0730 .zoom .mybatis .query .annotation .OrLike .class ;
19+ }
20+
21+
22+ @ Override
23+ public void buildQuery (QueryWrapper <?> queryWrapper , String column , @ Nonnull Object value ) {
24+ queryWrapper .or ().like (column , value );
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments