mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-30 06:01:27 +08:00
42
kit/flow/node.go
Normal file
42
kit/flow/node.go
Normal file
@@ -0,0 +1,42 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user