data_ini.go 1.1 KB

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