Browse Source

修改接口

yjp 1 year ago
parent
commit
df868d9a5b
1 changed files with 19 additions and 1 deletions
  1. 19 1
      convenient/domain/query_rule/query_rule_parser.go

+ 19 - 1
convenient/domain/query_rule/query_rule_parser.go

@@ -71,7 +71,7 @@ func HasRule(dbSchema string, scope string, domainName string, i *infrastructure
 	})
 }
 
-func FormConditions(dbSchema string, scope string, domainName string, i *infrastructure.Infrastructure) (*sql.Conditions, error) {
+func GetRules(dbSchema string, scope string, domainName string, i *infrastructure.Infrastructure) ([]Rule, error) {
 	dbExecutor := i.DBExecutor()
 
 	result, err := database.QueryOne(dbExecutor, &sql.QueryOneExecuteParams{
@@ -88,6 +88,10 @@ func FormConditions(dbSchema string, scope string, domainName string, i *infrast
 		return nil, err
 	}
 
+	return rules, nil
+}
+
+func FormConditions(rules []Rule) (*sql.Conditions, error) {
 	conditions := sql.NewConditions()
 	for _, r := range rules {
 		err := r.Check()
@@ -148,3 +152,17 @@ func FormConditions(dbSchema string, scope string, domainName string, i *infrast
 
 	return conditions, nil
 }
+
+func GetRulesAndFormConditions(dbSchema string, scope string, domainName string, i *infrastructure.Infrastructure) (*sql.Conditions, error) {
+	rules, err := GetRules(dbSchema, scope, domainName, i)
+	if err != nil {
+		return nil, err
+	}
+
+	conditions, err := FormConditions(rules)
+	if err != nil {
+		return nil, err
+	}
+
+	return conditions, nil
+}