这是一个创建于 538 天前的主题,其中的信息可能已经有所发展或是发生改变。
入参类似这种
{
"type": "rules_relation",
"relation": "and",
"rules": [
{
"type": "rules_relation",
"relation": "or",
"rules": [
{
"type": "profile_rule",
"field": "user.gender",
"function": "equal",
"params": [
"男"
],
"cname": "性别",
"icon": "user-property"
},
{
"type": "profile_rule",
"field": "user.city",
"function": "equal",
"params": [
"北京"
],
"cname": "城市",
"icon": "user-property"
}
]
}
]
}
我是应该直接根据入参用代码实现解析成 sql 的条件,然后拼接还是采用 antlr4 这种解析器?
5 条回复 2024-04-25 09:30:25 +08:00  | | 1 penny11 2024-04-24 19:16:01 +08:00 via iPhone 递归遍历这颗树,就翻译成 sql 了啊。。。 |
 | | 2 cydian 2024-04-24 20:54:27 +08:00 实现 DSL ,也就是你说的 antlr4 ,有其他更优的解析器选择 |
 | | 3 Keppel 2024-04-25 09:05:31 +08:00 入参举个例子,实际比这复杂 |
 | | 4 Keppel 2024-04-25 09:05:42 +08:00 |