You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.9 KiB
50 lines
1.9 KiB
1 month ago
|
package model
|
||
|
|
||
1 month ago
|
import (
|
||
|
"gofaster/internal/shared/model"
|
||
|
"time"
|
||
|
)
|
||
1 month ago
|
|
||
|
type Workflow struct {
|
||
1 month ago
|
model.BaseModel
|
||
1 month ago
|
Name string `json:"name"`
|
||
|
Description string `json:"description"`
|
||
1 month ago
|
Status int `json:"status"` // 1-启用 2-禁用
|
||
|
Nodes []WorkflowNode `json:"nodes" gorm:"foreignKey:WorkflowID"` // 添加外键定义
|
||
1 month ago
|
}
|
||
|
|
||
|
type WorkflowNode struct {
|
||
1 month ago
|
model.BaseModel
|
||
1 month ago
|
WorkflowID uint `json:"workflow_id" gorm:"index"` // 添加索引
|
||
1 month ago
|
Name string `json:"name"`
|
||
|
Type string `json:"type"` // start, end, task, approval等
|
||
|
Handler string `json:"handler"` // 处理函数
|
||
|
NextNodes string `json:"next_nodes"` // 逗号分隔的下个节点ID
|
||
|
Position int `json:"position"`
|
||
1 month ago
|
// 可选:添加回Workflow的引用
|
||
|
Workflow Workflow `json:"-" gorm:"foreignKey:WorkflowID"`
|
||
1 month ago
|
}
|
||
|
|
||
|
type WorkflowInstance struct {
|
||
1 month ago
|
model.BaseModel
|
||
1 month ago
|
WorkflowID uint `json:"workflow_id"`
|
||
|
Status string `json:"status"` // running, completed, canceled
|
||
|
CurrentNodeID uint `json:"current_node_id"`
|
||
1 month ago
|
Data string `json:"data" gorm:"type:text"` // JSON格式的业务数据
|
||
|
Tasks []WorkflowTask `json:"tasks" gorm:"foreignKey:InstanceID"` // 添加外键定义
|
||
1 month ago
|
}
|
||
|
|
||
|
type WorkflowTask struct {
|
||
1 month ago
|
model.BaseModel
|
||
1 month ago
|
InstanceID uint `json:"instance_id" gorm:"index"` // 添加索引
|
||
1 month ago
|
NodeID uint `json:"node_id"`
|
||
|
Status string `json:"status"` // pending, processing, completed, canceled
|
||
|
Result string `json:"result" gorm:"type:text"` // JSON格式的处理结果
|
||
|
Handler string `json:"handler"`
|
||
|
Assignee uint `json:"assignee"` // 处理人
|
||
|
StartTime time.Time `json:"start_time"`
|
||
|
EndTime time.Time `json:"end_time"`
|
||
1 month ago
|
// 可选:添加回WorkflowInstance的引用
|
||
|
Instance WorkflowInstance `json:"-" gorm:"foreignKey:InstanceID"`
|
||
1 month ago
|
}
|