1
This commit is contained in:
@ -10,7 +10,9 @@ import (
|
||||
// 字典 key 可以配置到 自动任务 调用目标 中;
|
||||
func InitJob() {
|
||||
jobList = map[string]JobExec{
|
||||
"ExamplesOne": ExamplesOne{},
|
||||
"ExamplesOne": ExamplesOne{},
|
||||
"TransferStatusJob": TransferStatusJob{},
|
||||
"TransferJob": TransferJob{},
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import (
|
||||
|
||||
type TransferJob struct{}
|
||||
|
||||
type TransferStatusJob struct{}
|
||||
|
||||
// 定期转账
|
||||
func (t TransferJob) Exec(arg interface{}) error {
|
||||
walletService := service.WmWalletInfo{}
|
||||
@ -29,3 +31,12 @@ func getDefaultDb() *gorm.DB {
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
// 定时查询交易状态
|
||||
func (t TransferStatusJob) Exec(arg interface{}) error {
|
||||
walletService := service.WmTransfer{}
|
||||
walletService.Orm = getDefaultDb()
|
||||
walletService.Log = logger.NewHelper(logger.DefaultLogger)
|
||||
|
||||
return walletService.CheckHashStatus()
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package jobs
|
||||
|
||||
import (
|
||||
"go-admin/config"
|
||||
helper "go-admin/utils/redishelper"
|
||||
"testing"
|
||||
|
||||
"github.com/go-admin-team/go-admin-core/sdk"
|
||||
@ -17,7 +18,23 @@ func TestTransferJob(t *testing.T) {
|
||||
config.ExtConfig.ApiEndpoint = "https://stylish-cool-fire.ethereum-sepolia.quiknode.pro/17572db4c091accfa5dc6faa0c60a805e5173459"
|
||||
config.ExtConfig.ProxyUrl = "http://127.0.0.1:7890"
|
||||
|
||||
helper.InitDefaultRedis("http://127.0.0.1:6379", "", 15) // 初始化配置
|
||||
|
||||
job := TransferJob{}
|
||||
|
||||
job.Exec(nil)
|
||||
}
|
||||
|
||||
// 测试状态任务
|
||||
func TestTransferStatusJob(t *testing.T) {
|
||||
dsn := "root:123456@tcp(127.0.0.1:3306)/eth_transfer?charset=utf8mb4&parseTime=True&loc=Local&timeout=1000ms"
|
||||
db, _ := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||
sdk.Runtime.SetDb("default", db)
|
||||
|
||||
config.ExtConfig.ApiEndpoint = "https://stylish-cool-fire.ethereum-sepolia.quiknode.pro/17572db4c091accfa5dc6faa0c60a805e5173459"
|
||||
config.ExtConfig.ProxyUrl = "http://127.0.0.1:7890"
|
||||
|
||||
job := TransferStatusJob{}
|
||||
|
||||
job.Exec(nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user