Some checks failed
		
		
	
	Build / build (push) Has been cancelled
				
			CodeQL / Analyze (go) (push) Has been cancelled
				
			build / Build (push) Has been cancelled
				
			GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
				
			GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
				
			Issue Close Require / issue-close-require (push) Has been cancelled
				
			2、查询平台剩余字符数
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package jobs
 | ||
| 
 | ||
| import (
 | ||
| 	"fmt"
 | ||
| 	"time"
 | ||
| )
 | ||
| 
 | ||
| // InitJob
 | ||
| // 需要将定义的struct 添加到字典中;
 | ||
| // 字典 key 可以配置到 自动任务 调用目标 中;
 | ||
| func InitJob() {
 | ||
| 	jobList = map[string]JobExec{
 | ||
| 		"ExamplesOne":          ExamplesOne{},
 | ||
| 		"DailyJob":             DailyJob{},
 | ||
| 		"RemainCharJob":        RemainCharJob{},
 | ||
| 		"CleanExpiredOrderJob": CleanExpiredOrderJob{},
 | ||
| 		"TrxPaymentJob":        TrxPaymentJob{},
 | ||
| 		// ...
 | ||
| 	}
 | ||
| }
 | ||
| 
 | ||
| // 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
 | ||
| }
 |