From f91a3ff89777effce99a5b9d41a1b7fa5d8169af Mon Sep 17 00:00:00 2001 From: zijiren <84728412+zijiren233@users.noreply.github.com> Date: Thu, 21 Nov 2024 17:30:30 +0800 Subject: [PATCH] fix: group api param id (#5224) --- service/aiproxy/controller/group.go | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/service/aiproxy/controller/group.go b/service/aiproxy/controller/group.go index 142e4f96333..9a097da1775 100644 --- a/service/aiproxy/controller/group.go +++ b/service/aiproxy/controller/group.go @@ -125,21 +125,28 @@ func GetGroupDashboard(c *gin.Context) { } type UpdateGroupQPMRequest struct { - ID string `json:"id"` - QPM int64 `json:"qpm"` + QPM int64 `json:"qpm"` } func UpdateGroupQPM(c *gin.Context) { + id := c.Param("id") + if id == "" { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "invalid parameter", + }) + return + } req := UpdateGroupQPMRequest{} err := json.NewDecoder(c.Request.Body).Decode(&req) - if err != nil || req.ID == "" { + if err != nil { c.JSON(http.StatusOK, gin.H{ "success": false, "message": "invalid parameter", }) return } - err = model.UpdateGroupQPM(req.ID, req.QPM) + err = model.UpdateGroupQPM(id, req.QPM) if err != nil { c.JSON(http.StatusOK, gin.H{ "success": false, @@ -154,21 +161,28 @@ func UpdateGroupQPM(c *gin.Context) { } type UpdateGroupStatusRequest struct { - ID string `json:"id"` - Status int `json:"status"` + Status int `json:"status"` } func UpdateGroupStatus(c *gin.Context) { + id := c.Param("id") + if id == "" { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "invalid parameter", + }) + return + } req := UpdateGroupStatusRequest{} err := json.NewDecoder(c.Request.Body).Decode(&req) - if err != nil || req.ID == "" { + if err != nil { c.JSON(http.StatusOK, gin.H{ "success": false, "message": "invalid parameter", }) return } - err = model.UpdateGroupStatus(req.ID, req.Status) + err = model.UpdateGroupStatus(id, req.Status) if err != nil { c.JSON(http.StatusOK, gin.H{ "success": false,