这是一个创建于 177 天前的主题,其中的信息可能已经有所发展或是发生改变。
入参类似这种
{
"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 177 天前 via iPhone
递归遍历这颗树,就翻译成 sql 了啊。。。
|
|
|
2
cydian 177 天前
实现 DSL ,也就是你说的 antlr4 ,有其他更优的解析器选择
|