修复错误配置探针最后通信时间的问题
This commit is contained in:
1 parent
5f0495af9c
commit
2e87bc56a8
1 file changed
+8
-4
@@ -22,13 +22,17 @@ func NewAgentRepo(db *gorm.DB) *AgentRepo {
|
||||
|
||||
// UpdateStatus 更新探针状态
|
||||
func (r *AgentRepo) UpdateStatus(ctx context.Context, agentID string, status int, lastSeenAt int64) error {
|
||||
m := map[string]interface{}{
|
||||
"status": status,
|
||||
}
|
||||
if lastSeenAt > 0 {
|
||||
m["last_seen_at"] = lastSeenAt
|
||||
}
|
||||
|
||||
return r.db.WithContext(ctx).
|
||||
Model(&models.Agent{}).
|
||||
Where("id = ?", agentID).
|
||||
Updates(map[string]interface{}{
|
||||
"status": status,
|
||||
"last_seen_at": lastSeenAt,
|
||||
}).Error
|
||||
Updates(m).Error
|
||||
}
|
||||
|
||||
// FindOnlineAgents 查找所有在线探针
|
||||
|
||||
Reference in new issue
Block a user