fix: 网元状态变更记录更新时间
This commit is contained in:
@@ -221,8 +221,10 @@ func (r NeInfo) UpdateState(id int64, status int64) int64 {
|
|||||||
tx := db.DB("").Model(&model.NeInfo{})
|
tx := db.DB("").Model(&model.NeInfo{})
|
||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
tx = tx.Where("id = ?", id)
|
tx = tx.Where("id = ?", id)
|
||||||
|
tx.UpdateColumn("status", status)
|
||||||
|
tx.UpdateColumn("update_time", time.Now().UnixMilli())
|
||||||
// 执行更新
|
// 执行更新
|
||||||
if err := tx.UpdateColumn("status", status).Error; err != nil {
|
if err := tx.Error; err != nil {
|
||||||
logger.Errorf("update err => %v", err.Error())
|
logger.Errorf("update err => %v", err.Error())
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/constants"
|
"be.ems/src/framework/constants"
|
||||||
"be.ems/src/framework/database/redis"
|
"be.ems/src/framework/database/redis"
|
||||||
@@ -181,6 +182,7 @@ func (r NeInfo) bandNeStatus(arr *[]model.NeInfo) {
|
|||||||
if v.Status != 0 {
|
if v.Status != 0 {
|
||||||
v.Status = 0
|
v.Status = 0
|
||||||
(*arr)[i].Status = v.Status
|
(*arr)[i].Status = v.Status
|
||||||
|
(*arr)[i].UpdateTime = time.Now().UnixMilli()
|
||||||
r.neInfoRepository.UpdateState(v.ID, v.Status)
|
r.neInfoRepository.UpdateState(v.ID, v.Status)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -198,6 +200,7 @@ func (r NeInfo) bandNeStatus(arr *[]model.NeInfo) {
|
|||||||
}
|
}
|
||||||
(*arr)[i].Status = status
|
(*arr)[i].Status = status
|
||||||
if v.Status != status {
|
if v.Status != status {
|
||||||
|
(*arr)[i].UpdateTime = time.Now().UnixMilli()
|
||||||
r.neInfoRepository.UpdateState(v.ID, status)
|
r.neInfoRepository.UpdateState(v.ID, status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user