|
|
@@ -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
|
|
|
+}
|