data_ini.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package controllers
  2. import (
  3. "eta/eta_task/models"
  4. "eta/eta_task/services"
  5. "eta/eta_task/utils"
  6. "github.com/beego/beego/v2/server/web"
  7. "time"
  8. )
  9. type DataInitController struct {
  10. web.Controller
  11. }
  12. func (c *DataInitController) InitEdbRelation() {
  13. br := new(models.BaseResponse).Init()
  14. defer func() {
  15. c.Data["json"] = br
  16. c.ServeJSON()
  17. }()
  18. cacheKey := "eta_task:InitEdbRelation"
  19. deleteCache := true
  20. defer func() {
  21. if deleteCache {
  22. utils.Rc.Delete(cacheKey)
  23. }
  24. }()
  25. if !utils.Rc.SetNX(cacheKey, 1, 5*time.Minute) {
  26. deleteCache = false
  27. br.Msg = `系统处理中,请稍后重试!`
  28. return
  29. }
  30. services.InitChartEdbRelation()
  31. services.InitChartCrossVariety()
  32. services.InitCalendarIndicatorRelation()
  33. services.InitSandBoxEdbRelation()
  34. services.InitExcelEdbRelation()
  35. br.Ret = 200
  36. br.Success = true
  37. br.Msg = "处理成功"
  38. }
  39. func (c *DataInitController) DisableEdbRefresh() {
  40. br := new(models.BaseResponse).Init()
  41. defer func() {
  42. c.Data["json"] = br
  43. c.ServeJSON()
  44. }()
  45. br.Ret = 200
  46. br.Success = true
  47. br.Msg = "处理成功"
  48. }