43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package biz
|
|
|
|
import (
|
|
"ai_scheduler/internal/biz/do"
|
|
"ai_scheduler/internal/entitys"
|
|
"context"
|
|
|
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
|
|
)
|
|
|
|
// AiRouterBiz 智能路由服务
|
|
type DingTalkBotBiz struct {
|
|
do *do.Do
|
|
handle *do.Handle
|
|
}
|
|
|
|
// NewDingTalkBotBiz
|
|
func NewDingTalkBotBiz(
|
|
do *do.Do,
|
|
handle *do.Handle,
|
|
) *DingTalkBotBiz {
|
|
return &DingTalkBotBiz{
|
|
do: do,
|
|
handle: handle,
|
|
}
|
|
}
|
|
|
|
func (d *DingTalkBotBiz) InitRequire(ctx context.Context, data *chatbot.BotCallbackDataModel) (requireData *entitys.RequireDataDingTalkBot, err error) {
|
|
requireData = &entitys.RequireDataDingTalkBot{
|
|
Req: data,
|
|
Ch: make(chan entitys.Response, 2),
|
|
}
|
|
entitys.ResLog(requireData.Ch, "recognize_start", "收到消息,正在处理中,请稍等")
|
|
|
|
requireData.Sys, err = d.do.GetSysInfoForDingTalkBot(requireData)
|
|
requireData.Tasks, err = d.do.GetTasks(requireData.Sys.SysID)
|
|
return
|
|
}
|
|
|
|
func (d *DingTalkBotBiz) Recognize(ctx context.Context, rec *entitys.Recognize, ch chan entitys.Response) (match *entitys.Match, err error) {
|
|
return d.handle.RecognizeBot(ctx, rec, ch)
|
|
}
|