feat: 添加工作流取消与临时文件管理功能
- 新增临时文件(FileTemp)的实体、DAO和DTO,支持文件临时存储与批量操作 - 实现工作流执行取消功能,使用sync.Map管理context.CancelFunc,支持按会话取消运行中的流程 - 将流程执行状态"暂停"变更为"取消",并处理取消导致的错误 - 引入IsDialogue标识区分对话模式,调整判断/文案/图片节点的表单数据组装逻辑 - 重构ComposeMessagesReq,使用BuildType替代IsBuild和ModelTypeId - 优化HTML内容提取逻辑,修复文案纯文本与图片URL的标签过滤及标签命名 - 在结果汇总节点中使用事务更新执行状态并批量保存输出文件记录
This commit is contained in:
45
workflow/model/dto/file/file_temp_dto.go
Normal file
45
workflow/model/dto/file/file_temp_dto.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type CreateFileTempReq struct {
|
||||
g.Meta `path:"/create" method:"post" tags:"临时文件管理" summary:"创建临时文件" dc:"创建临时文件"`
|
||||
|
||||
BusinessId string `json:"businessId"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
}
|
||||
|
||||
type CreateFileTempRes struct {
|
||||
Id int64 `json:"id,string"`
|
||||
}
|
||||
|
||||
type DeleteFileTempReq struct {
|
||||
g.Meta `path:"/delete" method:"delete" tags:"临时文件管理" summary:"删除临时文件" dc:"删除临时文件"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
type ListFileTempReq struct {
|
||||
g.Meta `path:"/list" method:"get" tags:"临时文件管理" summary:"临时文件列表" dc:"临时文件列表"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
BusinessId string `json:"businessId"`
|
||||
CreatedAt *gtime.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
type ListFileTempRes struct {
|
||||
List []*FileTempVO `json:"list"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type FileTempVO struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
BusinessId string `json:"businessId"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
@@ -17,6 +17,7 @@ type NodeExecutionInput struct {
|
||||
|
||||
// FlowExecutionInput 工作流执行入参(全程不变)
|
||||
type FlowExecutionInput struct {
|
||||
IsDialogue bool `json:"isDialogue"`
|
||||
ExecutionId int64 `json:"executionId"`
|
||||
ConfigMap map[string]*entity.FlowNode `json:"configMap"`
|
||||
SessionId string `json:"sessionId" dc:"会话ID"`
|
||||
@@ -27,15 +28,15 @@ type FlowExecutionInput struct {
|
||||
}
|
||||
|
||||
type ComposeMessagesReq struct {
|
||||
ModelTypeId int `json:"modelTypeId"`
|
||||
ModelName string `json:"modelName"`
|
||||
SkillName string `json:"skillName"`
|
||||
Form map[string]any `json:"form"`
|
||||
UserForm map[string]any `json:"userForm"`
|
||||
UserFiles []string `json:"userFiles"`
|
||||
SessionId string `json:"sessionId" dc:"会话ID"`
|
||||
IsBuild bool `json:"isBuild"`
|
||||
Cause string `json:"cause"`
|
||||
BuildType int `json:"buildType"`
|
||||
ModelName string `json:"modelName"`
|
||||
SkillName string `json:"skillName"`
|
||||
Form map[string]any `json:"form"`
|
||||
UserForm map[string]any `json:"userForm"`
|
||||
UserFiles []string `json:"userFiles"`
|
||||
SessionId string `json:"sessionId" dc:"会话ID"`
|
||||
IsBuild bool `json:"isBuild"`
|
||||
Cause string `json:"cause"`
|
||||
}
|
||||
|
||||
type ComposeMessagesRes struct {
|
||||
@@ -143,9 +144,9 @@ type ExecuteRes struct {
|
||||
}
|
||||
|
||||
type CancelReq struct {
|
||||
g.Meta `path:"/cancel" method:"get" tags:"任务管理" summary:"取消任务" dc:"取消任务"`
|
||||
g.Meta `path:"/cancel" method:"post" tags:"任务管理" summary:"取消任务" dc:"取消任务"`
|
||||
|
||||
FlowId int64 `json:"flowId" dc:"用户流程ID"`
|
||||
SessionId string `json:"sessionId" dc:"会话ID"`
|
||||
}
|
||||
|
||||
type CreateFlowExecutionReq struct {
|
||||
@@ -195,19 +196,21 @@ type ListFlowExecutionRes struct {
|
||||
}
|
||||
|
||||
type VOFlowExecution struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
FlowUserId int64 `json:"flowUserId,string" description:"流程ID"`
|
||||
FlowName string `json:"flowName"`
|
||||
TriggerType flow.FlowExecutionTriggerType `json:"triggerType" description:"触发类型"`
|
||||
DurationMs int64 `json:"durationMs" description:"执行时长(毫秒)"`
|
||||
Status flow.FlowExecutionStatus `json:"status" description:"状态:1-运行中,2-成功,3-失败"`
|
||||
FlowContent *entity.FlowInfo `json:"flowContent" description:"流程内容"`
|
||||
NodeInputParams []*entity.FlowNode `json:"nodeInputParams" description:"节点输入参数"`
|
||||
OutputParams []map[string]interface{} `json:"outputParams" description:"输出参数"`
|
||||
ErrorMessage string `json:"errorMessage" description:"错误信息"`
|
||||
TraceId string `json:"traceId" description:"跟踪ID"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
FlowUserId int64 `json:"flowUserId,string" description:"流程ID"`
|
||||
FlowName string `json:"flowName"`
|
||||
TriggerType flow.FlowExecutionTriggerType `json:"triggerType" description:"触发类型"`
|
||||
DurationMs int64 `json:"durationMs" description:"执行时长(毫秒)"`
|
||||
Status flow.FlowExecutionStatus `json:"status" description:"状态:1-运行中,2-成功,3-失败"`
|
||||
FlowContent *entity.FlowInfo `json:"flowContent" description:"流程内容"`
|
||||
NodeInputParams []*entity.FlowNode `json:"nodeInputParams" description:"节点输入参数"`
|
||||
OutputParams []map[string]interface{} `json:"outputParams" description:"输出参数"`
|
||||
ErrorMessage string `json:"errorMessage" description:"错误信息"`
|
||||
TraceId string `json:"traceId" description:"跟踪ID"`
|
||||
SessionId string `json:"sessionId" dc:"会话ID"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
ImgAddressPrefix string `json:"imgAddressPrefix"`
|
||||
}
|
||||
|
||||
// ========== 核心:构建树状结构 ==========
|
||||
|
||||
@@ -11,7 +11,6 @@ type CreateSkillTemplateReq struct {
|
||||
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Category string `json:"category"`
|
||||
FileName string `json:"fileName"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
}
|
||||
@@ -20,12 +19,30 @@ type CreateSkillTemplateRes struct {
|
||||
Id int64 `json:"id,string"`
|
||||
}
|
||||
|
||||
type UpdateSkillTemplateReq struct {
|
||||
g.Meta `path:"/update" method:"put" tags:"Skill技能管理" summary:"修改Skill用户技能" dc:"修改Skill用户技能"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
FileName string `json:"fileName"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
}
|
||||
|
||||
type DeleteSkillTemplateReq struct {
|
||||
g.Meta `path:"/delete" method:"delete" tags:"Skill技能管理" summary:"删除Skill技能" dc:"删除Skill技能"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
type GetSkillTemplateReq struct {
|
||||
g.Meta `path:"/get" method:"get" tags:"Skill技能管理" summary:"Skill技能详情" dc:"Skill技能详情"`
|
||||
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
NotInId int64 `json:"notInId"`
|
||||
}
|
||||
|
||||
type ListSkillTemplateReq struct {
|
||||
g.Meta `path:"/list" method:"get" tags:"Skill技能管理" summary:"Skill技能列表" dc:"Skill技能列表"`
|
||||
|
||||
@@ -42,7 +59,6 @@ type SkillTemplateVO struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Category string `json:"category"`
|
||||
FileName string `json:"fileName"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
|
||||
@@ -11,7 +11,6 @@ type CreateSkillUserReq struct {
|
||||
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Category string `json:"category"`
|
||||
FileName string `json:"fileName"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
}
|
||||
@@ -20,12 +19,40 @@ type CreateSkillUserRes struct {
|
||||
Id int64 `json:"id,string"`
|
||||
}
|
||||
|
||||
type UpdateSkillUserReq struct {
|
||||
g.Meta `path:"/update" method:"put" tags:"Skill用户技能管理" summary:"修改Skill用户技能" dc:"修改Skill用户技能"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
FileName string `json:"fileName"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
}
|
||||
|
||||
type DeleteSkillUserReq struct {
|
||||
g.Meta `path:"/delete" method:"delete" tags:"Skill用户技能管理" summary:"删除Skill用户技能" dc:"删除Skill用户技能"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
type GetSkillUserReq struct {
|
||||
g.Meta `path:"/get" method:"get" tags:"Skill用户技能管理" summary:"Skill用户技能详情" dc:"Skill用户技能详情"`
|
||||
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Creator string `json:"creator"`
|
||||
NotInId int64 `json:"notInId"`
|
||||
}
|
||||
|
||||
type GetSkillReq struct {
|
||||
g.Meta `path:"/getUserOrTemplate" method:"get" tags:"Skill用户技能管理" summary:"Skill技能详情" dc:"Skill技能详情"`
|
||||
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Creator string `json:"creator"`
|
||||
NotInId int64 `json:"notInId"`
|
||||
}
|
||||
|
||||
type ListSkillReq struct {
|
||||
g.Meta `path:"/list" method:"get" tags:"Skill用户技能管理" summary:"Skill用户技能列表" dc:"Skill用户技能列表"`
|
||||
|
||||
@@ -48,12 +75,12 @@ type ListSkillUserRes struct {
|
||||
}
|
||||
|
||||
type SkillUserVO struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Category string `json:"category"`
|
||||
FileName string `json:"fileName"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
FileName string `json:"fileName"`
|
||||
FileUrl string `json:"fileUrl"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
ImgAddressPrefix string `json:"imgAddressPrefix"`
|
||||
}
|
||||
|
||||
24
workflow/model/entity/file_temp.go
Normal file
24
workflow/model/entity/file_temp.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
type FileTemp struct {
|
||||
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段:Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
|
||||
|
||||
BusinessId string `orm:"business_id" json:"businessId"`
|
||||
FileUrl string `orm:"file_url" json:"fileUrl"`
|
||||
}
|
||||
|
||||
type fileTempCol struct {
|
||||
beans.SQLBaseCol
|
||||
BusinessId string
|
||||
FileUrl string
|
||||
}
|
||||
|
||||
var FileTempCol = fileTempCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
BusinessId: "business_id",
|
||||
FileUrl: "file_url",
|
||||
}
|
||||
@@ -9,7 +9,6 @@ type SkillTemplate struct {
|
||||
|
||||
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"`
|
||||
}
|
||||
@@ -18,7 +17,6 @@ type skillTemplateCol struct {
|
||||
beans.SQLBaseCol
|
||||
Name string
|
||||
Description string
|
||||
Category string
|
||||
FileName string
|
||||
FileUrl string
|
||||
}
|
||||
@@ -27,7 +25,6 @@ var SkillTemplateCol = skillTemplateCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
Name: "name",
|
||||
Description: "description",
|
||||
Category: "category",
|
||||
FileName: "file_name",
|
||||
FileUrl: "file_url",
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ type SkillUser struct {
|
||||
|
||||
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"`
|
||||
}
|
||||
@@ -16,7 +15,6 @@ type skillUserCol struct {
|
||||
beans.SQLBaseCol
|
||||
Name string
|
||||
Description string
|
||||
Category string
|
||||
FileName string
|
||||
FileUrl string
|
||||
}
|
||||
@@ -25,7 +23,6 @@ var SkillUserCol = skillUserCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
Name: "name",
|
||||
Description: "description",
|
||||
Category: "category",
|
||||
FileName: "file_name",
|
||||
FileUrl: "file_url",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user