示例#1
0
func (c *MockContentController) Enable() {
	id, _ := strconv.Atoi(c.Ctx.Input.Param(":id"))
	o := orm.NewOrm()

	var content models.MockContent
	content.Id = id
	err := o.Read(&content)
	if err != nil {
		c.ShowError(err.Error())
		return
	}

	o.QueryTable("mock_content").Filter("rule_id", content.RuleId).Update(orm.Params{"enable": "0"})
	content.Enable = true
	_, err = o.Update(&content)
	if err != nil {
		c.ShowError(err.Error())
		return
	}

	refreshRuleCache()
	c.ShowSuccess(nil)
}