2025-07-12 15:25:26 +08:00
|
|
|
|
package jobs
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
"time"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// InitJob
|
|
|
|
|
|
// 需要将定义的struct 添加到字典中;
|
|
|
|
|
|
// 字典 key 可以配置到 自动任务 调用目标 中;
|
|
|
|
|
|
func InitJob() {
|
|
|
|
|
|
jobList = map[string]JobExec{
|
2025-07-12 18:16:36 +08:00
|
|
|
|
"ExamplesOne": ExamplesOne{},
|
|
|
|
|
|
"TrxPaymentJob": TrxPaymentJob{},
|
|
|
|
|
|
"CliProxyTrafficsJob": CliProxyJob{},
|
2025-07-28 18:15:40 +08:00
|
|
|
|
"RenewalJob": RenewalJob{}, //长效ip定时续期
|
|
|
|
|
|
"ExpireProxyJob": ExpireProxyJob{}, //定时过期代理
|
|
|
|
|
|
"CleanExpiredOrderJob": CleanExpiredOrderJob{}, //清理过期订单
|
|
|
|
|
|
"SmsJob": SmsJob{}, //短信定时查询验证码
|
|
|
|
|
|
"SmsRenewalJob": SmsRenewalJob{}, //短信定时自动续期
|
2025-07-29 18:16:12 +08:00
|
|
|
|
"AutoDeleteJob": AutoDeleteJob{}, //定时删除任务
|
2025-08-23 16:38:04 +08:00
|
|
|
|
"SmsPriceJob": SmsPriceJob{}, // 短信价格定时同步
|
2025-07-12 15:25:26 +08:00
|
|
|
|
// ...
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ExamplesOne
|
|
|
|
|
|
// 新添加的job 必须按照以下格式定义,并实现Exec函数
|
|
|
|
|
|
type ExamplesOne struct {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (t ExamplesOne) Exec(arg interface{}) error {
|
|
|
|
|
|
str := time.Now().Format(timeFormat) + " [INFO] JobCore ExamplesOne exec success"
|
|
|
|
|
|
// TODO: 这里需要注意 Examples 传入参数是 string 所以 arg.(string);请根据对应的类型进行转化;
|
|
|
|
|
|
switch arg.(type) {
|
|
|
|
|
|
|
|
|
|
|
|
case string:
|
|
|
|
|
|
if arg.(string) != "" {
|
|
|
|
|
|
fmt.Println("string", arg.(string))
|
|
|
|
|
|
fmt.Println(str, arg.(string))
|
|
|
|
|
|
} else {
|
|
|
|
|
|
fmt.Println("arg is nil")
|
|
|
|
|
|
fmt.Println(str, "arg is nil")
|
|
|
|
|
|
}
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|