chore: trt to fix restore bool val #70

This commit is contained in:
duorameng
2026-04-18 13:04:53 +08:00
parent 1bd7082f33
commit 4b644e272e
17 changed files with 62 additions and 45 deletions
+4 -4
View File
@@ -72,7 +72,7 @@ func (c *AgentController) Update(ctx *gin.Context) {
utils.NotFound(ctx, "Agent 不存在")
return
}
wasEnabled := oldAgent.Enabled
wasEnabled := utils.DerefBool(oldAgent.Enabled, true)
if err := c.agentService.Update(id, req.Name, req.Description, req.Enabled); err != nil {
utils.ServerError(ctx, err.Error())
@@ -233,7 +233,7 @@ func (c *AgentController) GetTasks(ctx *gin.Context) {
return
}
if !agent.Enabled {
if !utils.DerefBool(agent.Enabled, true) {
utils.Forbidden(ctx, "Agent 已禁用")
return
}
@@ -259,7 +259,7 @@ func (c *AgentController) ReportResult(ctx *gin.Context) {
return
}
if !agent.Enabled {
if !utils.DerefBool(agent.Enabled, true) {
utils.Forbidden(ctx, "Agent 已禁用")
return
}
@@ -393,7 +393,7 @@ func (c *AgentController) WSConnect(ctx *gin.Context) {
logger.Infof("[AgentWS] 注册成功: Agent #%s, isNew=%v", agent.ID, isNewAgent)
}
if !agent.Enabled {
if !utils.DerefBool(agent.Enabled, true) {
c.wsManager.RecordConnectFail(ip)
logger.Warnf("[AgentWS] Agent #%s 已禁用, IP=%s", agent.ID, ip)
ctx.JSON(http.StatusForbidden, gin.H{"error": "Agent 已禁用"})