yjp 3 місяців тому
батько
коміт
8c0fde40af

+ 4 - 4
pipeline/component/component.go

@@ -2,7 +2,7 @@ package component
 
 import (
 	"errors"
-	"strings"
+	"git.sxidc.com/go-tools/utils/strutils"
 	"sync"
 )
 
@@ -26,7 +26,7 @@ func RegisterComponentBuilders(builders ...Builder) error {
 
 	for _, builder := range builders {
 		nodeType := builder.ProductType()
-		if strings.TrimSpace(nodeType) == "" {
+		if strutils.IsStringEmpty(nodeType) {
 			return errors.New("节点类型名称不能为空")
 		}
 
@@ -52,11 +52,11 @@ func UnRegisterComponents(typeNames []string) {
 }
 
 func BuildComponent(typeName string, name string, buildParams map[string]any, runParams map[string]any) (Component, error) {
-	if strings.TrimSpace(typeName) == "" {
+	if strutils.IsStringEmpty(typeName) {
 		return nil, errors.New("没有传递类型名称")
 	}
 
-	if strings.TrimSpace(name) == "" {
+	if strutils.IsStringEmpty(name) {
 		return nil, errors.New("没有传递名称")
 	}
 

+ 3 - 3
pipeline/component/flow/flow.go

@@ -3,7 +3,7 @@ package flow
 import (
 	"errors"
 	"git.sxidc.com/go-tools/utils/pipeline/component"
-	"strings"
+	"git.sxidc.com/go-tools/utils/strutils"
 )
 
 type SubComponentBuildParams struct {
@@ -14,11 +14,11 @@ type SubComponentBuildParams struct {
 }
 
 func (params *SubComponentBuildParams) Check(parentNodeType string) error {
-	if strings.TrimSpace(params.Type) == "" {
+	if strutils.IsStringEmpty(params.Type) {
 		return errors.New(parentNodeType + "没有传递子节点类型")
 	}
 
-	if strings.TrimSpace(params.Name) == "" {
+	if strutils.IsStringEmpty(params.Name) {
 		return errors.New(parentNodeType + "没有传递子节点名称")
 	}
 

+ 5 - 5
pipeline/definition.go

@@ -4,8 +4,8 @@ import (
 	"errors"
 	"git.sxidc.com/go-tools/utils/pipeline/component"
 	"git.sxidc.com/go-tools/utils/pipeline/component/flow"
+	"git.sxidc.com/go-tools/utils/strutils"
 	"github.com/fatih/structs"
-	"strings"
 )
 
 type Definition struct {
@@ -14,7 +14,7 @@ type Definition struct {
 }
 
 func (def *Definition) Check() error {
-	if strings.TrimSpace(def.Name) == "" {
+	if strutils.IsStringEmpty(def.Name) {
 		return errors.New("流水线没有传递名称")
 	}
 
@@ -40,11 +40,11 @@ type ComponentDefinition struct {
 }
 
 func (def *ComponentDefinition) Check() error {
-	if strings.TrimSpace(def.Type) == "" {
+	if strutils.IsStringEmpty(def.Type) {
 		return errors.New("组件没有传递类型")
 	}
 
-	if strings.TrimSpace(def.Name) == "" {
+	if strutils.IsStringEmpty(def.Name) {
 		return errors.New("组件没有传递名称")
 	}
 
@@ -78,7 +78,7 @@ func (def *Definition) NewPipeline() (*Pipeline, error) {
 }
 
 func newPipelineWithBuildParams(name string, params *flow.SeqBuildParams) (*Pipeline, error) {
-	if strings.TrimSpace(name) == "" {
+	if strutils.IsStringEmpty(name) {
 		return nil, errors.New("没有传递流水线的名称")
 	}
 

+ 5 - 5
pipeline/pipeline.go

@@ -5,9 +5,9 @@ import (
 	"git.sxidc.com/go-tools/utils/fileutils"
 	"git.sxidc.com/go-tools/utils/pipeline/component"
 	"git.sxidc.com/go-tools/utils/pipeline/component/flow"
+	"git.sxidc.com/go-tools/utils/strutils"
 	"gopkg.in/yaml.v3"
 	"os"
-	"strings"
 )
 
 func init() {
@@ -43,7 +43,7 @@ func (p *Pipeline) Run(globalRunParams map[string]any, dynamicParams map[string]
 }
 
 func NewPipelineFromYaml(yamlPath string) (*Pipeline, error) {
-	if strings.TrimSpace(yamlPath) == "" {
+	if strutils.IsStringEmpty(yamlPath) {
 		return nil, errors.New("没有传递流水线定义文件")
 	}
 
@@ -66,7 +66,7 @@ func NewPipelineFromYaml(yamlPath string) (*Pipeline, error) {
 }
 
 func NewPipelineFromYamlStr(yamlStr string) (*Pipeline, error) {
-	if strings.TrimSpace(yamlStr) == "" {
+	if strutils.IsStringEmpty(yamlStr) {
 		return nil, errors.New("没有传递流水线定义")
 	}
 
@@ -80,7 +80,7 @@ func NewPipelineFromYamlStr(yamlStr string) (*Pipeline, error) {
 }
 
 func LoadDynamicParamsFromYaml(yamlPath string) (map[string]any, error) {
-	if strings.TrimSpace(yamlPath) == "" {
+	if strutils.IsStringEmpty(yamlPath) {
 		return nil, errors.New("没有传递流水线动态参数文件不存在")
 	}
 
@@ -103,7 +103,7 @@ func LoadDynamicParamsFromYaml(yamlPath string) (map[string]any, error) {
 }
 
 func LoadDynamicParamsFromYamlStr(yamlStr string) (map[string]any, error) {
-	if strings.TrimSpace(yamlStr) == "" {
+	if strutils.IsStringEmpty(yamlStr) {
 		return nil, errors.New("没有传递流水线动态参数不存在")
 	}
 

+ 2 - 2
pipeline/test/test_node/bool.go

@@ -4,9 +4,9 @@ import (
 	"errors"
 	"fmt"
 	"git.sxidc.com/go-tools/utils/pipeline/component"
+	"git.sxidc.com/go-tools/utils/strutils"
 	"github.com/mitchellh/mapstructure"
 	"math/rand"
-	"strings"
 )
 
 const (
@@ -38,7 +38,7 @@ func (n *BoolNode) Run(globalRunParams *component.GlobalRunParams, dynamicParams
 				return nil, errors.New(TypeBool + "节点运行时参数Decode失败: " + err.Error())
 			}
 
-			if strings.TrimSpace(params.Operation) == "" {
+			if strutils.IsStringEmpty(params.Operation) {
 				params.Operation = BoolOperationPass
 			}