killme2008 / killme2008/aviatorscript
如果判断执行规则表达式时是否需要全部参数?
- Dominant language
- Java
- Stars
- 5.2k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
# 需求简介
我现在有一个需求:业务人员可以在后台管理页面配置规则表达式,在表达式执行成功后可以执行一些业务上的动作,对于规则表达式执行的最终结果只有true和false两种情况。
比如:swid == '{d3ee173d-9909-4798-951c-bc07714da6e6}' && id=='123',表示只有swid等于{d3ee173d-9909-4798-951c-bc07714da6e6} 并且 id等于123时,规则校验通过,返回true;其他情况则规则校验失败,返回false。规则表达式结果返回true,则可以执行一些后续的业务操作。
# 存在的问题
规则表达式中会有很多参数,有些参数是可以获取到的,有些参数获取成本较高。我希望可以用已有的参数去预先执行一次规则表达式,如果可以得到明确结果,则不去获取剩下的参数;如果缺失参数的情况下无法执行得到明确结果,则去获取剩下的参数后,再次执行规则表达式。
比如:
表达式:swid == '{d3ee173d-9909-4798-951c-bc07714da6e6}' && id=='123'
第一次传入参数为:swid = '{d3ee173d-9909-4798-951c-bc07714da6e6}‘
执行结果为:无法确定。因为没有id参数,所以无法判断第二个条件是否成立。此时需要去获取id参数。
第二次传入参数为:swid = 1
执行结果为:false。因为此时不管有没有id参数,对结果无影响,所以就直接返回false。
第三次传入参数为:swid = '{d3ee173d-9909-4798-951c-bc07714da6e6}‘、id='123'
执行结果为:true。因为此时两个条件都成立,结果是true。
该怎么解决此问题?
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files, tests, or entry points. Start by locating the expression evaluator and parameter-resolution code, then clarify how partial inputs should represent an indeterminate result and how the three swid/id examples should be verified; maintainer clarification is needed before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100