Browse Source

新增工作流提交接口

pull/52/head
JeshuaRen 7 months ago
parent
commit
3323f54d0f
1 changed files with 66 additions and 0 deletions
  1. +66
    -0
      sdks/scheduler/jobflow.go

+ 66
- 0
sdks/scheduler/jobflow.go View File

@@ -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"`
}

Loading…
Cancel
Save