Add two preference edit api.

This commit is contained in:
lishuang
2020-07-11 14:40:03 +08:00
parent 69820bfcb9
commit 096eb7c73e
9 changed files with 186 additions and 25 deletions

75
code/rest/task_service.go Normal file
View File

@ -0,0 +1,75 @@
package rest
import (
"github.com/eyebluecn/tank/code/core"
"github.com/robfig/cron"
)
// system tasks service
//@Service
type TaskService struct {
BaseBean
footprintService *FootprintService
dashboardService *DashboardService
}
func (this *TaskService) Init() {
this.BaseBean.Init()
b := core.CONTEXT.GetBean(this.footprintService)
if b, ok := b.(*FootprintService); ok {
this.footprintService = b
}
b = core.CONTEXT.GetBean(this.dashboardService)
if b, ok := b.(*DashboardService); ok {
this.dashboardService = b
}
}
//init the clean footprint task.
func (this *TaskService) InitCleanFootprintTask() {
this.logger.Info("[cron job] Every day 00:10 delete Footprint data of 8 days ago.")
expression := "0 10 0 * * ?"
cronJob := cron.New()
err := cronJob.AddFunc(expression, this.footprintService.CleanOldData)
core.PanicError(err)
cronJob.Start()
}
//init the elt task.
func (this *TaskService) InitEtlTask() {
this.logger.Info("[cron job] Everyday 00:05 ETL dashboard data.")
expression := "0 5 0 * * ?"
cronJob := cron.New()
err := cronJob.AddFunc(expression, this.dashboardService.Etl)
core.PanicError(err)
cronJob.Start()
}
//init the scan task.
func (this *TaskService) InitScanTask() {
this.logger.Info("[cron job] Everyday 00:05 ETL dashboard data.")
expression := "0 5 0 * * ?"
cronJob := cron.New()
err := cronJob.AddFunc(expression, this.dashboardService.Etl)
core.PanicError(err)
cronJob.Start()
}
func (this *TaskService) Bootstrap() {
//load the clean footprint task.
this.InitCleanFootprintTask()
//load the etl task.
this.InitEtlTask()
}