From d1904951a8b6b24e4ae518cd69c003d60072fd1b Mon Sep 17 00:00:00 2001 From: bixiaoyan Date: Fri, 21 Mar 2025 16:06:39 +0800 Subject: [PATCH] Add Resource Relations Put interface --- controllers/resource.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/controllers/resource.go b/controllers/resource.go index 19cc91b..3d9aaf5 100644 --- a/controllers/resource.go +++ b/controllers/resource.go @@ -143,3 +143,23 @@ func (rrc *ResourceRelationsController) Get() { rrc.Data["json"] = &result rrc.ServeJSON() } + +func (rrc *ResourceRelationsController) Put() { + logs.Debug("handle resource relation PUT request") + rscID := rrc.Ctx.Input.Param(":rscID") + action := rrc.Ctx.Input.Param(":action") + data := rrc.Ctx.Input.RequestBody + + result := map[string]interface{}{} + if err := models.ResourceAction(rscID, action, data); err != nil { + result["action"] = false + result["error"] = err.Error() + } else { + result["action"] = true + result["info"] = gettext.Gettext("Action on resource success") + } + + rrc.Data["json"] = &result + rrc.ServeJSON() +} + -- Gitee