|
|
@@ -22,6 +22,7 @@ func isSupportedLogicalOperator(logicalOperator string) bool {
|
|
|
return logicalOperator == LogicalOperatorAnd || logicalOperator == LogicalOperatorOr
|
|
|
}
|
|
|
|
|
|
+// Rule 规则二叉树
|
|
|
type Rule struct {
|
|
|
LogicalOperator string `json:"logicalOperator"`
|
|
|
Left *Rule `json:"left"`
|
|
|
@@ -142,6 +143,23 @@ func FormConditionClause(dbSchema string, scope string, domainName string, i *in
|
|
|
return c, nil
|
|
|
}
|
|
|
|
|
|
+// FormConditionClauseByRules 使用Rule结构构造并返回条件语句
|
|
|
+// 参数:
|
|
|
+// - domainName: 领域名称
|
|
|
+// - rule: Rule的结构
|
|
|
+// - ruleParams: 规则参数
|
|
|
+// 返回值:
|
|
|
+// - 语句接口,当错误为nil时,语句接口也可能是nil,代表该规则并没有被赋值,所以是没有条件的
|
|
|
+// - 错误
|
|
|
+func FormConditionClauseByRules(domainName string, r Rule, ruleParams map[string]any) (clause.Clause, error) {
|
|
|
+ c, err := formConditionClause(domainName, r, ruleParams)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return c, nil
|
|
|
+}
|
|
|
+
|
|
|
func getEnabledRule(dbSchema string, scope string, domainName string, i *infrastructure.Infrastructure) (Rule, error) {
|
|
|
dbExecutor := i.DBExecutor()
|
|
|
|