You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
558 B

  1. package initialize
  2. import (
  3. "fmt"
  4. "gin-vue-admin/config"
  5. "gin-vue-admin/global"
  6. "gin-vue-admin/utils"
  7. )
  8. func Timer() {
  9. if global.GVA_CONFIG.Timer.Start {
  10. for _, detail := range global.GVA_CONFIG.Timer.Detail {
  11. fmt.Println(detail)
  12. go func(detail config.Detail) {
  13. global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() {
  14. err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval)
  15. if err != nil {
  16. fmt.Println("timer error:", err)
  17. }
  18. })
  19. }(detail)
  20. }
  21. }
  22. }