package biz import ( "ai_scheduler/internal/biz/do" "ai_scheduler/internal/entitys" "github.com/gofiber/fiber/v2/log" "github.com/gofiber/websocket/v2" ) // AiRouterBiz 智能路由服务 type AiRouterBiz struct { do *do.Do handle *do.Handle } // NewAiRouterBiz 创建路由服务 func NewAiRouterBiz( do *do.Do, handle *do.Handle, ) *AiRouterBiz { return &AiRouterBiz{ do: do, handle: handle, } } func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRequest) (err error) { //必要数据验证和获取 dos := r.do.InitCtx(req) //初始化通道/上下文 ctx, clearFunc := dos.MakeCh(c) defer clearFunc() //数据验证和收集 if err = dos.DataAuth(c); err != nil { log.Errorf("数据验证和收集失败: %s", err.Error()) return } //初始化通道/上下文 if err = r.handle.Recognize(ctx, dos.Ctx); err != nil { log.Errorf("意图识别失败: %s", err.Error()) return } //向下传递 if err = r.handle.HandleMatch(ctx, dos.Ctx); err != nil { log.Errorf("任务处理失败: %s", err.Error()) return } return }