feat: 增加工作流过程输出

This commit is contained in:
fuzhongyun 2025-11-27 14:51:54 +08:00
parent 8895f29963
commit a706948504
1 changed files with 38 additions and 2 deletions

View File

@ -48,6 +48,7 @@ type Envelope struct {
// bug_optimization_submit 工单回调 // bug_optimization_submit 工单回调
const ( const (
ActionBugOptimizationSubmitProcess = "bug_optimization_submit_process" // 工单过程回调
ActionBugOptimizationSubmitDone = "bug_optimization_submit_done" // 工单完成回调 ActionBugOptimizationSubmitDone = "bug_optimization_submit_done" // 工单完成回调
ActionBugOptimizationSubmitUpdate = "bug_optimization_submit_update" // 工单更新回调 ActionBugOptimizationSubmitUpdate = "bug_optimization_submit_update" // 工单更新回调
) )
@ -167,6 +168,18 @@ func (s *CallbackService) handleDingTalkCallback(c *fiber.Ctx, env Envelope) err
// 删除映射 // 删除映射
s.botTool.DelTaskMapping(env.TaskID) s.botTool.DelTaskMapping(env.TaskID)
return c.JSON(fiber.Map{"code": 0, "message": "ok"})
case ActionBugOptimizationSubmitProcess:
type processData struct {
Process string `json:"process"`
}
var data processData
if err := json.Unmarshal(env.Data, &data); err != nil {
return errorcode.ParamErr("invalid json: %v", err)
}
s.sendStreamLoading(sessionID, data.Process)
return c.JSON(fiber.Map{"code": 0, "message": "ok"}) return c.JSON(fiber.Map{"code": 0, "message": "ok"})
default: default:
return errorcode.ParamErr("unknown action: %s", env.Action) return errorcode.ParamErr("unknown action: %s", env.Action)
@ -194,6 +207,10 @@ func (s *CallbackService) getDingtalkReceivers(ctx context.Context, receiverIds
// sendStreamLog 发送流式日志 // sendStreamLog 发送流式日志
func (s *CallbackService) sendStreamLog(sessionID string, content string) { func (s *CallbackService) sendStreamLog(sessionID string, content string) {
if content == "" {
return
}
streamLog := entitys.Response{ streamLog := entitys.Response{
Index: constants.BotToolsBugOptimizationSubmit, Index: constants.BotToolsBugOptimizationSubmit,
Content: content, Content: content,
@ -205,6 +222,10 @@ func (s *CallbackService) sendStreamLog(sessionID string, content string) {
// sendStreamTxt 发送流式文本 // sendStreamTxt 发送流式文本
func (s *CallbackService) sendStreamTxt(sessionID string, content string) { func (s *CallbackService) sendStreamTxt(sessionID string, content string) {
if content == "" {
return
}
streamLog := entitys.Response{ streamLog := entitys.Response{
Index: constants.BotToolsBugOptimizationSubmit, Index: constants.BotToolsBugOptimizationSubmit,
Content: content, Content: content,
@ -214,6 +235,21 @@ func (s *CallbackService) sendStreamTxt(sessionID string, content string) {
s.gateway.SendToUid(sessionID, streamLogBytes) s.gateway.SendToUid(sessionID, streamLogBytes)
} }
// sendStreamLoading 发送流式加载过程
func (s *CallbackService) sendStreamLoading(sessionID string, content string) {
if content == "" {
return
}
streamLog := entitys.Response{
Index: constants.BotToolsBugOptimizationSubmit,
Content: content,
Type: entitys.ResponseLoading,
}
streamLogBytes := pkg.JsonByteIgonErr(streamLog)
s.gateway.SendToUid(sessionID, streamLogBytes)
}
// handleBugOptimizationSubmitUpdate 处理 bug 优化提交更新回调 // handleBugOptimizationSubmitUpdate 处理 bug 优化提交更新回调
func (s *CallbackService) handleBugOptimizationSubmitUpdate(ctx context.Context, taskData json.RawMessage) (string, *errorcode.BusinessErr) { func (s *CallbackService) handleBugOptimizationSubmitUpdate(ctx context.Context, taskData json.RawMessage) (string, *errorcode.BusinessErr) {
var data BugOptimizationSubmitUpdateData var data BugOptimizationSubmitUpdateData