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 {