Files
ai-agent/digitalhuman/controller/async_task_controller.go
2026-04-27 11:24:13 +08:00

31 lines
869 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package controller
import (
"context"
"digital-human/digitalhuman/model/dto"
"digital-human/digitalhuman/service"
"github.com/gogf/gf/v2/util/gconv"
)
type asyncTask struct{}
// AsyncTask 异步任务同步控制器(供定时任务服务调用)
var AsyncTask = new(asyncTask)
// SyncAsyncTasks 扫描待处理任务并同步状态/转移结果
func (c *asyncTask) SyncAsyncTasks(ctx context.Context, req *dto.SyncAsyncTasksReq) (res *dto.SyncAsyncTasksRes, err error) {
// 从上下文获取用户信息gfdb Hook 会自动填充)
if ctx.Value("userId") == nil {
ctx = context.WithValue(ctx, "userId", gconv.String(1))
}
if ctx.Value("userName") == nil {
ctx = context.WithValue(ctx, "userName", "admin")
}
if ctx.Value("tenantId") == nil {
ctx = context.WithValue(ctx, "tenantId", uint64(1))
}
return service.AsyncTask.Sync(ctx, req)
}