复杂条件组合问题
`SELECT * FROM st_mytable WHERE (campaignId=1 or SpotsPlanId=2) or (WebsiteName='a' and ChannelName='b') SELECT * FROM st_mytable WHERE (campaignId=1 or SpotsPlanId=2) and (WebsiteName='a' or ChannelName='b')``` 请问大佬 类似于这种条件怎么组合, @combine好像也不行?
目前可以用 @raw,具体见通用文档及 APIJSONBoot 的 DemoSQLConfig 中 RAW_MAP 配置。 后续会增强 @combine,支持多层嵌套与或非连接
备注:关于@raw的使用补充: https://github.com/Tencent/APIJSON/releases/tag/4.4.0
目前可以用 @raw,具体见通用文档及 APIJSONBoot 的 DemoSQLConfig 中 RAW_MAP 配置。 后续会增强 @combine,支持多层嵌套与或非连接
谢谢tommy,
这种方式
RAW_MAP.put("commentWhereItem1","(Comment.userId = 38710 AND Comment.momentId = 470)");
38710 和 470 我想动态传参数,这个有方法吗。
写个远程函数给前端传参调用,这个远程函数负责拼接 SQL 片段 key 并 put 到 RAW_MAP,注意强校验参数值的类型和格式防 SQL 注入。
RAW_MAP.put("(campaignId=1 OR SpotsPlanId=2) OR (WebsiteName='a' AND ChannelName='b')", "");
@28-HuaSheng 已支持复杂条件组合 https://github.com/Tencent/APIJSON/commit/2cc13dab41f658f729eb34684bd6c8f64d8fd0c2
http://localhost:8080/get/User[]
{
"User": {
"date>": "2017-02-01 11:21:50",
"name*~": "a",
"contactIdList<>": 82001,
"tag$": "%p%i%",
"@combine": "(date> | name*~) | (contactIdList<> & tag$)",
"@explain": true
}
}

http://localhost:8080/get/User[]
{
"User": {
"date>": "2017-02-01 11:21:50",
"name*~": "a",
"contactIdList<>": 82001,
"tag$": "%p%i%",
"@combine": "(date> | name*~) & (contactIdList<> | tag$)",
"@explain": true
}
}

@28-HuaSheng 已支持复杂条件组合 2cc13da
http://localhost:8080/get/User[]
{ "User": { "date>": "2017-02-01 11:21:50", "name*~": "a", "contactIdList<>": 82001, "tag$": "%p%i%", "@combine": "(date> | name*~) | (contactIdList<> & tag$)", "@explain": true } }
http://localhost:8080/get/User[]
{ "User": { "date>": "2017-02-01 11:21:50", "name*~": "a", "contactIdList<>": 82001, "tag$": "%p%i%", "@combine": "(date> | name*~) & (contactIdList<> | tag$)", "@explain": true } }
thanks
预计 5.0 发布,发布前可以直接引入源码,替代 maven 仓库/jar 包来使用
(( audit_type = 1
and audit_status = 2 )
or ( audit_type = 2
and audit_status in (1, 3) ))
@TommyLemon 大佬 这个我该怎么拼,参数audit_type存在相同的key不同的值,但是在json中不允许key相同啊 用@combine 没实现,有啥好办法吗
((
audit_type= 1 andaudit_status= 2 ) or (audit_type= 2 andaudit_statusin (1, 3) )) @TommyLemon 大佬 这个我该怎么拼,参数audit_type存在相同的key不同的值,但是在json中不允许key相同啊 用@combine 没实现,有啥好办法吗 可以把冲突的 key 条件换种等效方式
"audit_type":1,
"audit_status":2,
"audit_type{}":"=2", // 等效于 audit_type = 2
"audit_status{}":[1,3]
"@combine":"((audit_type & audit_status) | (audit_type{} & audit_status{}))"
"audit_type":2 还可以改为 "audit_type{}":[2], 另外各种功能符还可以加 & | 等逻辑运算符,单个条件值等效于不加,例如 "audit_type&{}":"=2" "audit_type|{}":[2]
https://github.com/Tencent/APIJSON/blob/master/Document.md#3.2
5.0 Release 有 @combine 条件任意组合的示例图 https://github.com/Tencent/APIJSON/releases/tag/5.0.0