From a70694850405f9d4f4912597c76215d2f214a0e5 Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Thu, 27 Nov 2025 14:51:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E8=BF=87=E7=A8=8B=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/services/callback.go | 40 +++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/internal/services/callback.go b/internal/services/callback.go index 13d3d54..415f7cb 100644 --- a/internal/services/callback.go +++ b/internal/services/callback.go @@ -48,8 +48,9 @@ type Envelope struct { // bug_optimization_submit 工单回调 const ( - ActionBugOptimizationSubmitDone = "bug_optimization_submit_done" // 工单完成回调 - ActionBugOptimizationSubmitUpdate = "bug_optimization_submit_update" // 工单更新回调 + ActionBugOptimizationSubmitProcess = "bug_optimization_submit_process" // 工单过程回调 + ActionBugOptimizationSubmitDone = "bug_optimization_submit_done" // 工单完成回调 + ActionBugOptimizationSubmitUpdate = "bug_optimization_submit_update" // 工单更新回调 ) // BugOptimizationSubmitDoneData 工单完成回调数据 @@ -167,6 +168,18 @@ func (s *CallbackService) handleDingTalkCallback(c *fiber.Ctx, env Envelope) err // 删除映射 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"}) default: return errorcode.ParamErr("unknown action: %s", env.Action) @@ -194,6 +207,10 @@ func (s *CallbackService) getDingtalkReceivers(ctx context.Context, receiverIds // sendStreamLog 发送流式日志 func (s *CallbackService) sendStreamLog(sessionID string, content string) { + if content == "" { + return + } + streamLog := entitys.Response{ Index: constants.BotToolsBugOptimizationSubmit, Content: content, @@ -205,6 +222,10 @@ func (s *CallbackService) sendStreamLog(sessionID string, content string) { // sendStreamTxt 发送流式文本 func (s *CallbackService) sendStreamTxt(sessionID string, content string) { + if content == "" { + return + } + streamLog := entitys.Response{ Index: constants.BotToolsBugOptimizationSubmit, Content: content, @@ -214,6 +235,21 @@ func (s *CallbackService) sendStreamTxt(sessionID string, content string) { 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 优化提交更新回调 func (s *CallbackService) handleBugOptimizationSubmitUpdate(ctx context.Context, taskData json.RawMessage) (string, *errorcode.BusinessErr) { var data BugOptimizationSubmitUpdateData