We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bean Searcher v3.1.x 及之前版本只支持静态的 or 条件,即在 @SearchBean 注解的 joinCond 里写 SQL 片段,例如:
@SearchBean
joinCond
@SearchBean(joinCond="name like ':value%' or phone = ':value%'") public class User { // ... }
它生的 SQL 片段是 name like '?%' or phone = '?%',这是使用了内嵌参数的语法:https://bs.zhxu.cn/guide/latest/params.html#%E6%99%AE%E9%80%9A%E5%86%85%E5%B5%8C%E5%8F%82%E6%95%B0
name like '?%' or phone = '?%'
但这有一个缺点,就是,如果前端没传参数 value 的话,JDBC 传的参数会是 null,这有时可能并不是我们期望的。 此时可以在 Controller 层判断一下参数,如果没传,就手动放一个 空串值进来,例如:
null
Controller
@GetMapping("/index") public SearchResult<User> index(@RequestParam Map<String, Object> params) { params.putIfAbsent("value", ""); // 如果没有,则给一个空值 return beanSearcher.search(User.class, params); }
The text was updated successfully, but these errors were encountered:
用 前缀 给参数分组,用新参数 gexpr 指定组之间的逻辑关系,例如:
gexpr
(a) 组条件: a.name=Jack a.age = 20
(b) 组条件: b.name=Tom
(c) 组条件: c.sex = 1
组表达式: gexpr=(a|b)&c
表示【(name=Jack 且 age=20)或(name=Tom)】且【sex=1】的查询条件
Sorry, something went wrong.
No branches or pull requests
Bean Searcher v3.1.x 及之前版本只支持静态的 or 条件,即在
@SearchBean
注解的joinCond
里写 SQL 片段,例如:它生的 SQL 片段是
name like '?%' or phone = '?%'
,这是使用了内嵌参数的语法:https://bs.zhxu.cn/guide/latest/params.html#%E6%99%AE%E9%80%9A%E5%86%85%E5%B5%8C%E5%8F%82%E6%95%B0但这有一个缺点,就是,如果前端没传参数 value 的话,JDBC 传的参数会是
null
,这有时可能并不是我们期望的。此时可以在
Controller
层判断一下参数,如果没传,就手动放一个 空串值进来,例如:The text was updated successfully, but these errors were encountered: