feat: Task scheduling supports function with parameters
注意:参数资源sql; ALTER TABLE `sys_job` ADD COLUMN `args` varchar(255) NULL COMMENT '目标参数' AFTER `invoke_target`;
This commit is contained in:
1 parent
242902d2bc
commit
b26258c8ab
5 files changed
+24
-6
No files matched your search
+16
-2
@@ -18,7 +18,21 @@ func InitJob() {
|
||||
type ExamplesOne struct {
|
||||
}
|
||||
|
||||
func (t ExamplesOne) Exec() {
|
||||
func (t ExamplesOne) Exec(arg interface{}) error {
|
||||
str := time.Now().Format(timeFormat) + " [INFO] JobCore ExamplesOne exec success"
|
||||
fmt.Println(str)
|
||||
// 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
|
||||
}
|
||||
Reference in new issue
Block a user