diff --git a/cmd/server/app/network/controller/agentcontroller/config.go b/cmd/server/app/network/controller/agentcontroller/config.go index f10468f60361a4e168939a0a9f901220b51a7052..3e6bda847ef3618c214b74b5e805928fcf16b846 100644 --- a/cmd/server/app/network/controller/agentcontroller/config.go +++ b/cmd/server/app/network/controller/agentcontroller/config.go @@ -9,6 +9,10 @@ import ( func ConfigfileHandler(c *gin.Context) { uuid := c.Query("uuid") + if uuid == "" { + response.Fail(c, nil, "uuid参数缺失") + return + } agent := agentmanager.GetAgent(uuid) if agent == nil { response.Fail(c, nil, "获取uuid失败!") diff --git a/cmd/server/app/network/controller/agentcontroller/cpu.go b/cmd/server/app/network/controller/agentcontroller/cpu.go index d2243967314642a22da4495f58504b126dd14f7d..87bcd90d41367084eef1d23c5b6a4f3a77d1a473 100644 --- a/cmd/server/app/network/controller/agentcontroller/cpu.go +++ b/cmd/server/app/network/controller/agentcontroller/cpu.go @@ -22,17 +22,20 @@ import ( func CPUInfoHandler(c *gin.Context) { uuid := c.Query("uuid") - + if uuid == "" { + response.Fail(c, nil, "uuid参数缺失") + return + } agent := agentmanager.GetAgent(uuid) if agent == nil { response.Fail(c, nil, "获取uuid失败!") return } - cpu_info, err := agent.GetCPUInfo() + cpuInfo, err := agent.GetCPUInfo() if err != nil { response.Fail(c, nil, "获取系统CPU信息失败!") return } - response.Success(c, gin.H{"CPU_info": cpu_info}, "Success") + response.Success(c, gin.H{"CPU_info": cpuInfo}, "Success") } diff --git a/cmd/server/app/network/controller/agentcontroller/cron.go b/cmd/server/app/network/controller/agentcontroller/cron.go index 6001607e01ab2918f72d7cb7f85b5a63ce4ddf61..69acd9d70c0ef4448eefd5eb32854941428a4f13 100644 --- a/cmd/server/app/network/controller/agentcontroller/cron.go +++ b/cmd/server/app/network/controller/agentcontroller/cron.go @@ -25,6 +25,7 @@ import ( "github.com/gin-gonic/gin" ) +// CreatCron 创建定时任务 func CreatCron(c *gin.Context) { // 存入数据库 var newCron cron.CrontabUpdate @@ -91,6 +92,7 @@ func CreatCron(c *gin.Context) { response.Success(c, gin.H{"data": newCron, "cron": cron_start}, "任务已生效") } +// DeleteCronTask 是一个删除定时任务的函数 func DeleteCronTask(c *gin.Context) { var crons cron.DelCrons var cronIds string @@ -114,6 +116,7 @@ func DeleteCronTask(c *gin.Context) { response.Success(c, nil, "任务删除成功!") } +// UpdateCron 是一个处理更新定时任务的函数 func UpdateCron(c *gin.Context) { var Cron cron.CrontabUpdate c.Bind(&Cron) @@ -157,6 +160,7 @@ func UpdateCron(c *gin.Context) { response.Success(c, gin.H{"cron": cron_start}, "任务更新成功,已开始执行") } +// CronTaskStatus 处理任务状态更新请求 func CronTaskStatus(c *gin.Context) { var Cron cron.CrontabUpdate c.Bind(&Cron) @@ -201,6 +205,7 @@ func CronTaskStatus(c *gin.Context) { response.Success(c, gin.H{"cron": cron_start}, "任务已开启") } +// CronTaskList 获取定时任务列表 func CronTaskList(c *gin.Context) { uuid := c.Query("uuid") @@ -211,8 +216,8 @@ func CronTaskList(c *gin.Context) { return } - num := query.Size * (query.CurrentPageNum - 1) - total, data, err := cron.CronListPaged(uuid, num, query.Size) + offset := query.Size * (query.CurrentPageNum - 1) + total, data, err := cron.CronListPaged(uuid, offset, query.Size) if err != nil { response.Fail(c, gin.H{"status": false}, err.Error()) return