修复错误配置探针最后通信时间的问题

This commit is contained in:
dushixiang committed 2025-12-02 22:12:23 +08:00
1 parent 5f0495af9c
commit 2e87bc56a8
1 file changed
+8 -4
+8 -4
View File
@@ -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 查找所有在线探针