feat: complete SOP execution workflow

This commit is contained in:
Eric 1549169735@qq.com
2026-08-09 00:29:26 +08:00
parent e32025d2ca
commit c5ab886b70
63 changed files with 1229 additions and 215 deletions

View File

@@ -13,6 +13,7 @@ type answerNodeConfig struct {
FieldKey string `json:"field_key"`
FieldKeys []string `json:"field_keys"`
Required bool `json:"required"`
Options []string `json:"options"`
}
func validateNodeAnswers(node model.SOPNode, fields []model.ScenarioField, answers map[string]interface{}) error {
@@ -68,10 +69,22 @@ func validateNodeAnswers(node model.SOPNode, fields []model.ScenarioField, answe
if err := validateFieldValue(field, value); err != nil {
return err
}
if node.Type == "choice" && !stringAllowed(config.Options, fmt.Sprint(value)) {
return fmt.Errorf("%s的选项不正确", field.FieldName)
}
}
return nil
}
func stringAllowed(options []string, selected string) bool {
for _, option := range options {
if option == selected {
return true
}
}
return false
}
func validateFieldValue(field model.ScenarioField, value interface{}) error {
switch field.FieldType {
case "text", "textarea":