示例#1
0
func (this *CategoryController) Store() {
	pid, _ := strconv.Atoi(this.GetString("Pid"))
	name := this.GetString("Name")
	o := orm.NewOrm()
	category := new(models.Category)
	category.Pid = int64(pid)
	category.Name = name
	//category := &models.Category{Pid:int64(pid),Name:name}
	o.Insert(category)
	this.Redirect(beego.UrlFor("CategoryController.Index"), 302)

}
示例#2
0
func (this *CategoryController) Update() {
	id, _ := strconv.Atoi(this.GetString("Id"))
	name := this.GetString("Name")
	o := orm.NewOrm()
	category := models.Category{Id: int64(id)}
	error := o.Read(&category)
	if error != nil {
		beego.Error("error=", error)
	}
	beego.Debug("category=", category)
	category.Name = name
	beego.Debug("category=", category)
	o.Update(&category, "name")
	this.Redirect(beego.UrlFor("CategoryController.Index"), 302)
}