func Favor(c *gin.Context, favor int) { id, _ := strconv.Atoi(c.Param("id")) user_id := GetUser(c).ID panel := types.Panel{} response := gin.H{} defer c.JSON(http.StatusOK, response) if mydb.Table("panel").Where("id = ? and user_id = ?", id, user_id).First(&panel).RecordNotFound() { response["code"] = http.StatusNotFound response["message"] = "panel not found" return } panel.Favor = favor mydb.Table("panel").Select("favor").Save(&panel) response["code"] = http.StatusOK response["panel"] = panel }