Files
PandaX/kit/flow/node.go
lixxxww a329e336e0 提交kit/flow
Signed-off-by: lixxxww <941403820@qq.com>
2024-01-23 11:32:00 +00:00

43 lines
767 B
Go

package flow
import (
"pandax/kit/utils"
)
type Properties map[string]any
type Node struct {
Id string `json:"id"`
Type string `json:"type"`
X int `json:"x"`
Y int `json:"y"`
Text Text `json:"text"`
Properties Properties `json:"properties"`
}
type Text struct {
X int `json:"x"`
Y int `json:"y"`
Value string `json:"value"`
}
func (node *Node) IsStartNode(ty string) bool {
if node.Type == ty {
return true
}
return false
}
func (node *Node) GetProperties(data any) error {
if err := utils.Map2Struct(node.Properties, data); err != nil {
return err
}
return nil
}
type NodeFunc func(*Node)
func (node *Node) RunNodeFunc(nodeFunc NodeFunc) {
nodeFunc(node)
}