1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package service
- import (
- "time"
- "youngee_b_api/db"
- "github.com/robfig/cron/v3"
- log "github.com/sirupsen/logrus"
- )
- func AutoTask() error {
- c := cron.New()
- _, err1 := c.AddFunc("@midnight", AutoTaskUpdateStatus)
- if err1 != nil {
- log.Println("service [AutoTaskUpdateStatus] error:", err1)
- return err1
- }
- _, err2 := c.AddFunc("@midnight", AutoTaskUpdateApplyTimes)
- if err2 != nil {
- log.Println("service [AutoTaskUpdateApplyTimes] error:", err2)
- return err2
- }
- c.Start()
- return nil
- }
- func AutoTaskUpdateStatus() {
- err := db.AutoUpdateStatus()
- log.Println("AutoTaskUpdateStatus is running ,Time :", time.Now())
- if err != nil {
- log.Println("AutoTaskUpdateStatus error : ", err)
- }
- }
- func AutoTaskUpdateApplyTimes() {
- err := db.AutoUpdateApplyTimes()
- log.Println("AutoUpdateApplyTimes is running ,Time :", time.Now())
- if err != nil {
- log.Println("AutoUpdateApplyTimes error : ", err)
- }
- }
|