12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package data_manage
- import (
- "eta/eta_hub/utils"
- "github.com/beego/beego/v2/client/orm"
- )
- func EdbInfoUpdateStatusByEdbInfoId(edbInfoIds []int, isStop int, calculateEdbInfoIds []int) (err error) {
- o, err := orm.NewOrmUsingDB("data").Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- _ = o.Rollback()
- return
- }
- _ = o.Commit()
- }()
- // 更改指标的更新状态
- if len(edbInfoIds) == 1 {
- sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id=? `
- _, err = o.Raw(sql, isStop, edbInfoIds[0]).Exec()
- if err != nil {
- return
- }
- } else {
- sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(edbInfoIds)) + `) `
- _, err = o.Raw(sql, isStop, edbInfoIds).Exec()
- if err != nil {
- return
- }
- }
- if len(calculateEdbInfoIds) > 0 {
- // 批量更新相关联的指标ID
- sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(calculateEdbInfoIds)) + `) `
- _, err = o.Raw(sql, isStop, calculateEdbInfoIds).Exec()
- if err != nil {
- return
- }
- }
- return
- }
|