edb_data_wind.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package data_manage
  2. import (
  3. "eta/eta_hub/utils"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. func EdbInfoUpdateStatusByEdbInfoId(edbInfoIds []int, isStop int, calculateEdbInfoIds []int) (err error) {
  7. o, err := orm.NewOrmUsingDB("data").Begin()
  8. if err != nil {
  9. return
  10. }
  11. defer func() {
  12. if err != nil {
  13. _ = o.Rollback()
  14. return
  15. }
  16. _ = o.Commit()
  17. }()
  18. // 更改指标的更新状态
  19. if len(edbInfoIds) == 1 {
  20. sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id=? `
  21. _, err = o.Raw(sql, isStop, edbInfoIds[0]).Exec()
  22. if err != nil {
  23. return
  24. }
  25. } else {
  26. sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(edbInfoIds)) + `) `
  27. _, err = o.Raw(sql, isStop, edbInfoIds).Exec()
  28. if err != nil {
  29. return
  30. }
  31. }
  32. if len(calculateEdbInfoIds) > 0 {
  33. // 批量更新相关联的指标ID
  34. sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(calculateEdbInfoIds)) + `) `
  35. _, err = o.Raw(sql, isStop, calculateEdbInfoIds).Exec()
  36. if err != nil {
  37. return
  38. }
  39. }
  40. return
  41. }