target.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package services
  2. import (
  3. "eta/eta_api/models"
  4. "eta/eta_api/models/system"
  5. "eta/eta_api/utils"
  6. )
  7. // 新增指标数据
  8. func AddEdbItem(secName, unit, frequency string, classifyId int, sysUser *system.Admin) (errMsg string) {
  9. //保存edb数据
  10. tradeCode, err := models.GetMaxTradeCode()
  11. if err != nil {
  12. errMsg = "获取最大交易编码失败,Err:" + err.Error()
  13. return
  14. }
  15. if tradeCode == "" {
  16. errMsg = "最大编码为空"
  17. return
  18. }
  19. maxTradeCode, err := utils.GetMaxTradeCode(tradeCode)
  20. if err != nil {
  21. errMsg = "获取编码信息失败,Err:" + err.Error()
  22. return
  23. }
  24. if maxTradeCode == "" {
  25. errMsg = "编码为空,请联系技术"
  26. return
  27. }
  28. if secName == "" {
  29. errMsg = "指标名称不能为空"
  30. return
  31. }
  32. item, err := models.GetEdbinfoBySecName(secName)
  33. if err != nil && err.Error() != utils.ErrNoRow() {
  34. errMsg = "获取信息失败,Err:" + err.Error()
  35. return
  36. }
  37. if item != nil {
  38. errMsg = "指标名称已存在"
  39. return
  40. }
  41. err = models.AddEdbinfo(maxTradeCode, secName, unit, "手动", frequency, "", classifyId, sysUser.AdminId, sysUser.RealName)
  42. if err != nil {
  43. errMsg = "新增失败,Err:" + err.Error()
  44. return
  45. }
  46. err = models.AddEdbinfoUser(maxTradeCode, sysUser.Mobile)
  47. if err != nil {
  48. errMsg = "新增失败,Err:" + err.Error()
  49. return
  50. }
  51. return
  52. }