From 3323f54d0f2a04472dea59eff0e07cc843ec6071 Mon Sep 17 00:00:00 2001 From: JeshuaRen <270813223@qq.com> Date: Tue, 15 Apr 2025 14:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdks/scheduler/jobflow.go | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sdks/scheduler/jobflow.go diff --git a/sdks/scheduler/jobflow.go b/sdks/scheduler/jobflow.go new file mode 100644 index 0000000..7fa61b5 --- /dev/null +++ b/sdks/scheduler/jobflow.go @@ -0,0 +1,66 @@ +package schsdk + +import "time" + +type FlowData struct { + Nodes []Node `json:"nodes"` + Edges []Edge `json:"edges"` +} + +type Node struct { + ID string `json:"id"` + Type string `json:"type"` + X int `json:"x"` + Y int `json:"y"` + Properties JobInfo `json:"properties"` + Text *Text `json:"text,omitempty"` // 有些节点没有 text 字段 +} + +type Edge struct { + ID string `json:"id"` + Type string `json:"type"` + Properties interface{} `json:"properties"` // 为空对象 {} + SourceNodeID string `json:"sourceNodeId"` + TargetNodeID string `json:"targetNodeId"` + SourceAnchorID string `json:"sourceAnchorId"` + TargetAnchorID string `json:"targetAnchorId"` + StartPoint Point `json:"startPoint"` + EndPoint Point `json:"endPoint"` + PointsList []Point `json:"pointsList"` + Text *Text `json:"text,omitempty"` // 有些 edge 有文字标签 +} + +type Point struct { + X int `json:"x"` + Y int `json:"y"` +} + +type Text struct { + X int `json:"x"` + Y int `json:"y"` + Value string `json:"value"` +} + +type JobFlowDAO struct { + ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"ID"` + UserID int64 `gorm:"column:user_id;not null" json:"UserID"` + Name string `gorm:"column:name;size:255;not null" json:"Name"` + Description string `gorm:"column:description;size:255" json:"Description"` + Content string `gorm:"column:content;type:text" json:"Content"` + Status string `gorm:"column:status;type:enum('pending','running','fail','success');default:'pending'" json:"Status"` + JobType string `gorm:"column:job_type;size:255" json:"JobType"` + UpdatedAt time.Time `gorm:"column:update_at;autoUpdateTime" json:"UpdatedAt"` + CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"CreatedAt"` +} + +type JobFlow struct { + ID int64 `json:"ID"` + UserID int64 `json:"UserID"` + Name string `json:"Name"` + Description string `json:"Description"` + Content FlowData `json:"Content"` + Status string `json:"Status"` + JobType string `json:"JobType"` + UpdatedAt time.Time `json:"UpdatedAt"` + CreatedAt time.Time `json:"CreatedAt"` +}