From 5592e47f726dfacb9398560b661050e408c15841 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sun, 30 Mar 2025 19:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=99=AE=E9=80=9A=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=8A=9F=E8=83=BD=E8=8E=B7=E5=8F=96=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/func_model.go | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/handler/func_model.go b/handler/func_model.go index 47594fa..651559a 100644 --- a/handler/func_model.go +++ b/handler/func_model.go @@ -3,7 +3,6 @@ package handler import ( "StuAcaWorksAI/proto" "StuAcaWorksAI/service" - "encoding/json" "github.com/gin-gonic/gin" "net/http" ) @@ -22,12 +21,12 @@ type FunctionModelIDs struct { } type FuncModelReq struct { - ID int `json:"id" form:"id"` - ModelID int `json:"model_id" form:"model_id"` - Function string `json:"function" form:"function"` - Name string `json:"name" form:"name"` - Info string `json:"info" form:"info"` - ModelIDS []FunctionModelIDs `json:"model_ids" form:"model_ids"` + ID int `json:"id" form:"id"` + ModelID int `json:"model_id" form:"model_id"` + Function string `json:"function" form:"function"` + Name string `json:"name" form:"name"` + Info string `json:"info" form:"info"` + ModelIDS string `json:"model_ids" form:"model_ids"` } func CreateFuncModel(c *gin.Context) { @@ -35,13 +34,13 @@ func CreateFuncModel(c *gin.Context) { userID := int(id.(float64)) var req FuncModelReq if err := c.ShouldBind(&req); err == nil { - modelIDs, err3 := json.Marshal(req.ModelIDS) - if err3 != nil { - c.JSON(http.StatusOK, gin.H{"error": err3.Error(), "code": proto.FuncModelCreateFailed, "message": "failed"}) - return - } + //modelIDs, err3 := json.Marshal(req.ModelIDS) + //if err3 != nil { + // c.JSON(http.StatusOK, gin.H{"error": err3.Error(), "code": proto.FuncModelCreateFailed, "message": "failed"}) + // return + //} // 创建功能模型 - err2, mid := service.CreateFuncModel(int(uint(userID)), req.ModelID, req.Name, req.Info, req.Function, string(modelIDs)) + err2, mid := service.CreateFuncModel(int(uint(userID)), req.ModelID, req.Name, req.Info, req.Function, req.ModelIDS) if err2 == nil { c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": mid}) } else { @@ -84,13 +83,13 @@ func UpdateFuncModel(c *gin.Context) { userID := int(id.(float64)) var req FuncModelReq if err := c.ShouldBind(&req); err == nil { - modelIDs, err3 := json.Marshal(req.ModelIDS) - if err3 != nil { - c.JSON(http.StatusOK, gin.H{"error": err3.Error(), "code": proto.FuncModelCreateFailed, "message": "failed"}) - return - } + //modelIDs, err3 := json.Marshal(req.ModelIDS) + //if err3 != nil { + // c.JSON(http.StatusOK, gin.H{"error": err3.Error(), "code": proto.FuncModelCreateFailed, "message": "failed"}) + // return + //} // 修改功能模型 - err2 := service.UpdateFuncModelByID(req.ID, uint(userID), uint(req.ModelID), req.Name, req.Info, req.Function, string(modelIDs)) + err2 := service.UpdateFuncModelByID(req.ID, uint(userID), uint(req.ModelID), req.Name, req.Info, req.Function, req.ModelIDS) if err2 == nil { c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"}) } else {