コード例 #1
0
ファイル: panels.go プロジェクト: TalkingData/OWL-v3
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
}