feat: 新增会话管理 DTO

This commit is contained in:
2026-08-13 12:30:35 +08:00
parent 358c5ca3a7
commit 114563b4f0
+101
View File
@@ -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:"工作流IDchat类型为空)"`
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:"创建时间"`
}