yongyi.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package data
  2. import (
  3. "eta/eta_api/models/data_manage"
  4. "eta/eta_api/models/data_manage/request"
  5. "eta/eta_api/utils"
  6. "fmt"
  7. )
  8. // YongyiIndexSource2Edb 新增涌益咨询数据源到指标库
  9. func YongyiIndexSource2Edb(req request.YongyiIndexSource2EdbReq, lang string) (edb *data_manage.EdbInfo, err error, errMsg string, skip bool) {
  10. if req.EdbCode == "" {
  11. err = fmt.Errorf("指标ID为空")
  12. return
  13. }
  14. defer func() {
  15. if err != nil {
  16. tips := fmt.Sprintf("YongyiIndexSource2Edb新增失败, Err: %s", err.Error())
  17. fmt.Println(tips)
  18. utils.FileLog.Info(tips)
  19. }
  20. }()
  21. source := utils.DATA_SOURCE_YONYI
  22. // 是否新增过指标
  23. exist, e := data_manage.GetEdbInfoByEdbCode(source, req.EdbCode)
  24. if e != nil && e.Error() != utils.ErrNoRow() {
  25. err = fmt.Errorf("获取指标是否存在失败, err: %s", e.Error())
  26. return
  27. }
  28. if exist != nil {
  29. skip = true
  30. return
  31. }
  32. // 开始结束时间
  33. var startDate, endDate string
  34. // 新增指标库
  35. edbInfo, e, msg, _ := EdbInfoAdd(source, utils.DATA_SUB_SOURCE_EDB, req.ClassifyId, req.EdbCode, req.EdbName, req.Frequency, req.Unit, startDate, endDate, req.AdminId, req.AdminRealName, lang)
  36. if e != nil {
  37. errMsg = msg
  38. err = fmt.Errorf("EdbInfo: 新增指标失败, err: %s", e.Error())
  39. return
  40. }
  41. edb = edbInfo
  42. return
  43. }