|
@@ -20,7 +20,6 @@ func GetComponentClassify(c *gin.Context) {
|
|
|
} else {
|
|
|
e.ResponseSuccess(c, classify)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// AddComponentClassify 添加组件分类
|
|
@@ -63,5 +62,24 @@ func DeleteComponentClassify(c *gin.Context) {
|
|
|
|
|
|
// UpdateComponentClassify 更新组件分类
|
|
|
func UpdateComponentClassify(c *gin.Context) {
|
|
|
-
|
|
|
+ var componentClass model.ComponentClassify
|
|
|
+ s := c.Query("id")
|
|
|
+ err := c.ShouldBindJSON(&componentClass)
|
|
|
+ if err != nil {
|
|
|
+ e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ validate := validator.New()
|
|
|
+ err = validate.Var(s, "required,numeric")
|
|
|
+ if err != nil {
|
|
|
+ e.ResponseWithMsg(c, e.ERROR, "id不能为空")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ atoi, _ := strconv.Atoi(s)
|
|
|
+ id, err := unity.UpdateById(atoi, &componentClass)
|
|
|
+ if err != nil {
|
|
|
+ e.ResponseWithMsg(c, e.ERROR, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ e.ResponseSuccess(c, id)
|
|
|
}
|