data_fix.go 943 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_data_init/models"
  5. "eta/eta_data_init/services"
  6. beego "github.com/beego/beego/v2/server/web"
  7. )
  8. // DataFixController 数据修复
  9. type DataFixController struct {
  10. beego.Controller
  11. }
  12. // FixTableV1
  13. // @Title 数据修复
  14. // @Description 数据修复
  15. // @Success Ret=200
  16. // @router /fix/v1 [get]
  17. func (this *DataFixController) FixTableV1() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. method := "fix/v1"
  24. classifyFirstMap := make(map[string]interface{})
  25. result, err := services.PostEdbLib(classifyFirstMap, method)
  26. if err != nil {
  27. br.Msg = "修复失败"
  28. br.ErrMsg = "修复失败,ERR:" + err.Error()
  29. return
  30. }
  31. resp := new(models.BaseResp)
  32. err = json.Unmarshal(result, &resp)
  33. if err != nil {
  34. br.Msg = "修复失败," + resp.Msg
  35. br.ErrMsg = resp.ErrMsg
  36. return
  37. }
  38. br.Ret = 200
  39. br.Msg = "保存成功"
  40. }