go_dreamfactory/modules/timer/season.go

44 lines
1.1 KiB
Go

package timer
import (
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"time"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/cron"
)
type SeasonPagoda struct {
modules.MCompModel
service core.IService
dbName string
module *Timer
}
//组件初始化接口
func (this *SeasonPagoda) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TableSeasonPagoda
this.MCompModel.Init(service, module, comp, options)
this.service = service
this.module = module.(*Timer)
return
}
func (this *SeasonPagoda) Start() (err error) {
err = this.MCompModel.Start()
cron.AddFunc("0 0 23 L * ?", this.TimerSeasonOver) //每月最后一天23点执行一次
cron.AddFunc("0 0 5 /* * ?", this.TimerSeasonStar) //每月第一天5点执行一次
return
}
// // 赛季塔结束
func (this *SeasonPagoda) TimerSeasonOver() {
this.module.Debugf("TimerSeasonOver:%d", time.Now().Unix())
}
// 赛季塔开始
func (this *SeasonPagoda) TimerSeasonStar() {
this.module.Debugf("TimerSeasonStar:%d", time.Now().Unix())
}