Пример #1
0
func (c *CategoryController) Get() {
	op := c.Input().Get("op")
	switch op {
	case "add":
		category := c.Input().Get("category")
		if len(category) == 0 {
			break
		}
		err := models.AddCategory(category)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/category", 301)
		return

	case "del":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		err := models.DelCategory(id)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/category", 301)
	}

	c.Data["IsCategory"] = true
	c.TplNames = "category.html"
	var err error
	c.Data["Categories"], err = models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}
}
Пример #2
0
func (this *CategoryController) Get() {
	op := this.Input().Get("op")

	switch op {
	case "add":
		name := this.Input().Get("name")
		if len(name) == 0 {
			break
		}
		err := models.AddCategory(name)
		if err != nil {
			beego.Error(err)
		}
		this.Redirect("/category", 301)
		return
	case "del":
		println("ssssssss....................")

		id := this.Input().Get("id")
		if len(id) == 0 {
			break
		}

		println(".......category 1")

		err := models.DelCategory(id)

		println(".......category 2")

		if err != nil {
			beego.Error(err)
		}
		println(".......category 3")
		this.Redirect("/category", 301)
		return
	}

	this.TplNames = "category.html"
	this.Data["IsCategory"] = true

	var err error
	this.Data["Categories"], err = models.GetAllCategories()

	if err != nil {
		beego.Error(err)
	}
}
Пример #3
0
func (this *CategoryController) Get() {
	this.Data["IsCategory"] = true
	this.Data["IsLogin"] = checkAccount(this.Ctx)

	op := this.Input().Get("op")

	switch op {
	case "add":
		name := this.Input().Get("name")

		if len(name) == 0 {
			break
		}

		err := models.AddCategory(name)
		if err != nil {
			beego.Error(err)
		}

		this.Redirect("/category", 301)
		return
	case "del":
		id := this.Input().Get("id")
		if len(id) == 0 {
			break
		}

		err := models.DelCategory(id)

		if err != nil {
			beego.Error(err)
		}

		this.Redirect("/category", 301)
		return
	}

	var err error
	this.Data["Categories"], err = models.GetAllCategories()
	this.TplName = "category.html"

	if err != nil {
		beego.Error(err)
	}
}
Пример #4
0
func (c *CategroyController) Get() {

	op := c.Input().Get("op")
	switch op {
	case "add":
		cname := c.Input().Get("cname")
		if len(cname) == 0 {
			break
		}
		err := models.AddCategory(cname)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/category", 301)
		return
	case "del":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		err := models.DelCategory(id)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/category", 301)
		return
	default:
		c.Data["IsLogin"] = checkAccount(c.Ctx)
		c.Data["IsCategray"] = true
		c.TplNames = "categroy.html"
		var err error
		c.Data["Categories"], err = models.GetAllCategories()
		if err != nil {
			beego.Error(nil)
		}
	}

}