24 lines
577 B
Go
24 lines
577 B
Go
package task
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
"easygoadmin/internal/logic"
|
|
)
|
|
|
|
func init() {
|
|
logic.RegisterJobHandler("HelloWorld", helloWorld)
|
|
}
|
|
|
|
// helloWorld 示例任务
|
|
// 仅打印日志,用于验证调度链路
|
|
func helloWorld(ctx context.Context, params string) (string, error) {
|
|
now := time.Now().Format("2006-01-02 15:04:05")
|
|
g.Log().Infof(ctx, "[定时任务] HelloWorld 执行,时间: %s,参数: %s", now, paramsText(params))
|
|
return fmt.Sprintf("Hello World! 时间: %s | 参数: %s", now, paramsText(params)), nil
|
|
}
|