From 114563b4f00370301c54498b78e120e23cc84157 Mon Sep 17 00:00:00 2001 From: qhd <1766646056@qq.com> Date: Thu, 13 Aug 2026 12:30:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E7=AE=A1=E7=90=86=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workflow/model/dto/session/session_dto.go | 101 ++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 workflow/model/dto/session/session_dto.go diff --git a/workflow/model/dto/session/session_dto.go b/workflow/model/dto/session/session_dto.go new file mode 100644 index 0000000..67115c6 --- /dev/null +++ b/workflow/model/dto/session/session_dto.go @@ -0,0 +1,101 @@ +package session + +import ( + "gitea.redpowerfuture.com/red-future/common/beans" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// 结果状态(自包含,不复用 flow 的 *int8 指针类型) +const ( + ResultStatusRunning = 1 // 运行中 + ResultStatusSuccess = 2 // 成功 + ResultStatusFailed = 3 // 失败 +) + +type CreateSessionReq struct { + g.Meta `path:"/create" method:"post" tags:"会话管理" summary:"新建会话" dc:"新建会话"` + SessionName string `json:"sessionName" v:"required#会话名称不能为空" dc:"会话名称"` +} + +type CreateSessionRes struct { + Id int64 `json:"id,string" dc:"会话ID"` +} + +type ListSessionReq struct { + g.Meta `path:"/list" method:"get" tags:"会话管理" summary:"会话列表" dc:"会话列表"` + Page *beans.Page `json:"page"` +} + +type ListSessionRes struct { + List []*VOSession `json:"list"` + Total int `json:"total"` +} + +type VOSession struct { + Id int64 `json:"id,string" dc:"会话ID"` + SessionName string `json:"sessionName" dc:"会话名称"` + CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` +} + +type DeleteSessionReq struct { + g.Meta `path:"/delete" method:"post" tags:"会话管理" summary:"删除会话" dc:"删除会话,级联删除该会话下普通对话结果,工作流结果保留"` + Id int64 `json:"id" v:"required#会话ID不能为空"` +} + +type ListSessionResultsReq struct { + g.Meta `path:"/results" method:"get" tags:"会话管理" summary:"会话内结果列表" dc:"会话内结果列表,工作流+普通对话混排按时间倒序"` + SessionId int64 `json:"sessionId" v:"required#会话ID不能为空"` +} + +type ListSessionResultsRes struct { + List []*VOSessionResult `json:"list"` +} + +// VOSessionResult 会话内单条结果(工作流/普通对话混排) +type VOSessionResult struct { + ResultId int64 `json:"resultId,string" dc:"结果ID"` + Type string `json:"type" dc:"workflow-工作流结果,chat-普通对话结果"` + Status int `json:"status" dc:"1-运行中,2-成功,3-失败"` + FlowId int64 `json:"flowId,string" dc:"工作流ID(chat类型为空)"` + FlowName string `json:"flowName" dc:"工作流名称(chat类型为空)"` + Question string `json:"question" dc:"用户问题(workflow类型为空)"` + Answer string `json:"answer" dc:"模型返回结果(workflow类型为空)"` + RequestParams map[string]any `json:"requestParams" dc:"请求参数(workflow类型)"` + ResultParams []map[string]any `json:"resultParams" dc:"返回结果"` + TotalTokens int `json:"totalTokens" dc:"总token消耗"` + TotalFee float64 `json:"totalFee" dc:"总费用"` + ErrorMsg string `json:"errorMsg" dc:"错误信息"` + CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` +} + +type DeleteSessionResultReq struct { + g.Meta `path:"/resultDelete" method:"post" tags:"会话管理" summary:"删除单条结果" dc:"删除单条结果,不影响会话"` + Type string `json:"type" v:"required#结果类型不能为空" dc:"workflow-工作流结果,chat-普通对话结果"` + Id int64 `json:"id" v:"required#结果ID不能为空"` +} + +type ListWorkflowResultsReq struct { + g.Meta `path:"/workflowResults" method:"get" tags:"会话管理" summary:"工作流结果平铺列表" dc:"工作流维度所有结果平铺列表,含已删除会话下的结果"` + Page *beans.Page `json:"page"` + FlowId int64 `json:"flowId" dc:"按工作流ID过滤,可选"` +} + +type ListWorkflowResultsRes struct { + List []*VOWorkflowResult `json:"list"` + Total int `json:"total"` +} + +type VOWorkflowResult struct { + ResultId int64 `json:"resultId,string" dc:"结果ID"` + SessionId int64 `json:"sessionId,string" dc:"所属会话ID"` + FlowId int64 `json:"flowId,string" dc:"工作流ID"` + FlowName string `json:"flowName" dc:"工作流名称"` + RequestParams map[string]any `json:"requestParams" dc:"请求参数"` + ResultParams []map[string]any `json:"resultParams" dc:"返回结果"` + Status int `json:"status" dc:"1-运行中,2-成功,3-失败"` + TotalTokens int `json:"totalTokens" dc:"总token消耗"` + TotalFee float64 `json:"totalFee" dc:"总费用"` + ErrorMsg string `json:"errorMsg" dc:"错误信息"` + CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` +} \ No newline at end of file