From d9a289957ec8041ff74e30afc4f0d15b8a610a44 Mon Sep 17 00:00:00 2001 From: bixiaoyan Date: Thu, 13 Feb 2025 16:29:18 +0800 Subject: [PATCH] fix node put bug --- controllers/node.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/controllers/node.go b/controllers/node.go index e867716..0e58ae5 100644 --- a/controllers/node.go +++ b/controllers/node.go @@ -8,11 +8,13 @@ package controllers import ( + "encoding/json" "strings" "gitee.com/openeuler/ha-api/models" "gitee.com/openeuler/ha-api/utils" "github.com/beego/beego/v2/server/web" + "github.com/chai2010/gettext-go" ) type NodesController struct { @@ -68,8 +70,14 @@ type NodeActionController struct { func (nac *NodeActionController) Put() { nodeID := nac.Ctx.Input.Param(":nodeID") action := nac.Ctx.Input.Param(":action") - result := models.DoNodeAction(nodeID, action) - + reqData := make(map[string]string) + result := map[string]interface{}{} + if err := json.Unmarshal(nac.Ctx.Input.RequestBody, &reqData); err != nil { + result["action"] = false + result["error"] = gettext.Gettext("invalid input data") + } else { + result = models.DoNodeAction(nodeID, action, reqData) + } nac.Data["json"] = &result nac.ServeJSON() } -- Gitee