[feat] 定时任务支持

This commit is contained in:
what 2023-10-30 15:00:33 +08:00
parent 901767a1dc
commit 41bfdea63b
2 changed files with 33 additions and 0 deletions

18
base/cron.go Normal file
View File

@ -0,0 +1,18 @@
package base
type Cron struct {
Uuid string `db:"uuid"`
Code string `db:"code"`
Name string `db:"name"`
ResourceUuid string `db:"resource_uuid"`
Second string `db:"sec"`
Minute string `db:"min"`
Hour string `db:"hr"`
Day string `db:"day"`
Month string `db:"mo"`
Week string `db:"wk"`
UpdatedAt string `db:"updated_at"`
CreatedAt string `db:"created_at"`
}
type GetCron func(code string) (Cron, bool)

15
cron.go Normal file
View File

@ -0,0 +1,15 @@
package contracts
import "time"
type CronService interface {
Start() error
Stop() error
Restart() error
}
type Cron interface {
Controller
// 任务处理
Handle(time.Time) error
}