feat: 新增工作流执行模块

新增流程执行记录的实体、DTO、DAO、控制器和服务层,支持工作流的执行、回调及结果树状列表查询;同时更新服务名称为 ai-agent。
This commit is contained in:
2026-05-12 13:34:28 +08:00
parent 2aec7fe30f
commit 7c26914353
42 changed files with 4146 additions and 11 deletions

View File

@@ -0,0 +1,53 @@
package entity
import (
"ai-agent/workflow/consts/flow"
"gitea.com/red-future/common/beans"
)
type FlowExecution struct {
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
// 业务字段
FlowUserId int64 `orm:"flow_user_id" json:"flowUserId" description:"流程ID"`
FlowName string `orm:"flow_name" json:"flowName" description:"流程名称"`
TriggerType flow.FlowExecutionTriggerType `orm:"trigger_type" json:"triggerType" description:"触发类型"`
DurationMs int64 `orm:"duration_ms" json:"durationMs" description:"执行时长(毫秒)"`
Status flow.FlowExecutionStatus `orm:"status" json:"status" description:"状态:1-运行中,2-成功,3-失败"`
FlowContent *FlowInfo `orm:"flow_content" json:"flowContent" description:"流程内容"`
NodeInputParams []*FlowNode `orm:"node_input_params" json:"nodeInputParams" description:"节点输入参数"`
OutputParams []map[string]interface{} `orm:"output_params" json:"outputParams" description:"输出参数"`
ErrorMessage string `orm:"error_message" json:"errorMessage" description:"错误信息"`
TraceId string `orm:"trace_id" json:"traceId" description:"跟踪ID"`
SessionId string `orm:"session_id" json:"sessionId" description:"会话ID"`
}
type flowExecutionCol struct {
beans.SQLBaseCol
FlowUserId string
FlowName string
TriggerType string
DurationMs string
Status string
FlowContent string
NodeInputParams string
OutputParams string
ErrorMessage string
TraceId string
SessionId string
}
var FlowExecutionCol = flowExecutionCol{
SQLBaseCol: beans.DefSQLBaseCol,
FlowUserId: "flow_user_id",
FlowName: "flow_name",
TriggerType: "trigger_type",
DurationMs: "duration_ms",
Status: "status",
FlowContent: "flow_content",
NodeInputParams: "node_input_params",
OutputParams: "output_params",
ErrorMessage: "error_message",
TraceId: "trace_id",
SessionId: "session_id",
}

View File

@@ -0,0 +1,41 @@
package entity
import (
"ai-agent/workflow/consts/flow"
"gitea.com/red-future/common/beans"
)
type FlowTemplate struct {
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
// 业务字段
FlowTemplateName string `orm:"flow_template_name" json:"flowTemplateName" description:"流程模板名称"`
Description string `orm:"description" json:"description" description:"流程描述"`
CategoryCode string `orm:"category_code" json:"categoryCode" description:"流程分类"`
CategoryName string `orm:"category_name" json:"categoryName" description:"流程分类名称"`
FlowContent *FlowInfo `orm:"flow_content" json:"flowContent" description:"流程内容"`
NodeInputParams []*FlowNode `orm:"node_input_params" json:"nodeInputParams" description:"节点输入参数"`
Status flow.FlowTemplateStatus `orm:"status" json:"status" description:"流程状态1启用/0停用"`
}
type flowTemplateCol struct {
beans.SQLBaseCol
FlowTemplateName string
Description string
CategoryCode string
CategoryName string
FlowContent string
NodeInputParams string
Status string
}
var FlowTemplateCol = flowTemplateCol{
SQLBaseCol: beans.DefSQLBaseCol,
FlowTemplateName: "flow_template_name",
Description: "description",
CategoryCode: "category_code",
CategoryName: "category_name",
FlowContent: "flow_content",
NodeInputParams: "node_input_params",
Status: "status",
}

View File

@@ -0,0 +1,70 @@
package entity
import (
"ai-agent/workflow/consts/flow"
"ai-agent/workflow/consts/node"
"gitea.com/red-future/common/beans"
)
type FlowInfo struct {
Version string `json:"version"`
StartNodeId string `json:"startNodeId"`
Nodes []FlowNode `json:"nodes"`
Edges []FlowEdge `json:"edges"`
}
type FlowNode struct {
Id string `json:"id"`
NodeCode node.NodeType `json:"nodeCode"`
Name string `json:"name"`
Config map[string]interface{} `json:"config"`
SkillName string `json:"skillName"`
InputSource []FlowNodeInputSource `json:"inputSource"` // 前端指定来源节点ID
FormConfig []node.NodeFormField `json:"formConfig"`
ModelConfig node.ModelItem `json:"modelConfig"`
OutputResult []node.NodeFormField `json:"outputResult" ds:"节点输出结果"`
}
type FlowNodeInputSource struct {
NodeId string `json:"nodeId"`
QuoteOutput bool `json:"quoteOutput"`
Field []string `json:"field"`
}
type FlowEdge struct {
Id string `json:"id"`
From string `json:"from"`
To string `json:"to"`
}
type FlowUser struct {
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
// 业务字段
FlowName string `orm:"flow_name" json:"flowName" description:"流程名称"`
Description string `orm:"description" json:"description" description:"流程描述"`
FlowContent *FlowInfo `orm:"flow_content" json:"flowContent" description:"流程内容"`
NodeInputParams []*FlowNode `orm:"node_input_params" json:"nodeInputParams" description:"节点输入参数"`
AccessLevel flow.FlowUserAccessLevel `orm:"access_level" json:"accessLevel" description:"访问权限1私有2团队3公开"`
SourceFlowTemplateId int64 `orm:"source_flow_template_id" json:"sourceFlowTemplateId" description:"来源流程模板ID"`
}
type flowUserCol struct {
beans.SQLBaseCol
FlowName string
Description string
FlowContent string
NodeInputParams string
AccessLevel string
SourceFlowTemplateId string
}
var FlowUserCol = flowUserCol{
SQLBaseCol: beans.DefSQLBaseCol,
FlowName: "flow_name",
Description: "description",
FlowContent: "flow_content",
NodeInputParams: "node_input_params",
AccessLevel: "access_level",
SourceFlowTemplateId: "source_flow_template_id",
}

View File

@@ -0,0 +1,33 @@
package entity
import (
"gitea.com/red-future/common/beans"
)
type SkillTemplate struct {
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
Name string `orm:"name" json:"name"`
Description string `orm:"description" json:"description"`
Category string `orm:"category" json:"category"`
FileName string `orm:"file_name" json:"fileName"`
FileUrl string `orm:"file_url" json:"fileUrl"`
}
type skillTemplateCol struct {
beans.SQLBaseCol
Name string
Description string
Category string
FileName string
FileUrl string
}
var SkillTemplateCol = skillTemplateCol{
SQLBaseCol: beans.DefSQLBaseCol,
Name: "name",
Description: "description",
Category: "category",
FileName: "file_name",
FileUrl: "file_url",
}

View File

@@ -0,0 +1,31 @@
package entity
import "gitea.com/red-future/common/beans"
type SkillUser struct {
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
Name string `orm:"name" json:"name"`
Description string `orm:"description" json:"description"`
Category string `orm:"category" json:"category"`
FileName string `orm:"file_name" json:"fileName"`
FileUrl string `orm:"file_url" json:"fileUrl"`
}
type skillUserCol struct {
beans.SQLBaseCol
Name string
Description string
Category string
FileName string
FileUrl string
}
var SkillUserCol = skillUserCol{
SQLBaseCol: beans.DefSQLBaseCol,
Name: "name",
Description: "description",
Category: "category",
FileName: "file_name",
FileUrl: "file_url",
}