44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package services
|
|
|
|
import (
|
|
"ai_scheduler/internal/biz"
|
|
"ai_scheduler/internal/config"
|
|
"ai_scheduler/internal/data/constants"
|
|
"context"
|
|
|
|
"gitea.cdlsxd.cn/self-tools/l-dingtalk-stream-sdk-go/chatbot"
|
|
)
|
|
|
|
type CronService struct {
|
|
config *config.Config
|
|
dingTalkBotBiz *biz.DingTalkBotBiz
|
|
}
|
|
|
|
func NewCronService(config *config.Config, dingTalkBotBiz *biz.DingTalkBotBiz) *CronService {
|
|
return &CronService{
|
|
config: config,
|
|
dingTalkBotBiz: dingTalkBotBiz,
|
|
}
|
|
}
|
|
|
|
func (d *CronService) CronReportSend(ctx context.Context) error {
|
|
reportChan, err := d.dingTalkBotBiz.GetReportLists(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
groupId := 29
|
|
groupInfo, err := d.dingTalkBotBiz.GetGroupInfo(ctx, groupId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = d.dingTalkBotBiz.HandleStreamRes(ctx, &chatbot.BotCallbackDataModel{
|
|
RobotCode: groupInfo.RobotCode,
|
|
ConversationType: constants.ConversationTypeGroup,
|
|
ConversationId: groupInfo.ConversationID,
|
|
Text: chatbot.BotCallbackDataTextModel{
|
|
Content: "报表",
|
|
},
|
|
}, reportChan)
|
|
return nil
|
|
}
|