예제 #1
0
파일: category.go 프로젝트: senvid/mygo
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
파일: topic.go 프로젝트: GuoBug/beeblog
func (this *TopicController) Post() {
	if !checkAccount(this.Ctx) {
		this.Redirect("/login", 302)
	}
	/* 解析表单 */
	title := this.Input().Get("title")
	category := this.Input().Get("category")
	content := this.Input().Get("content")
	tid := this.Input().Get("tid")

	var err error

	if len(tid) == 0 {
		err = models.AddTopic(title, content, category)
		if models.CheckCategory(category) {
			beego.Debug("had")
			models.UpdateCategory(category)
		} else {
			beego.Debug("Not ! ")
			models.AddCategory(category)
		}
	} else {
		err = models.ModifyTopic(tid, title, content, category)
		if models.CheckCategory(category) {
			beego.Debug("had")
		} else {
			beego.Debug("Not ! ")
			models.AddCategory(category)
		}
	}
	if err != nil {
		beego.Error(err)
	}

	this.Redirect("/topic", 302)
}
예제 #3
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)
	}
}
예제 #4
0
파일: category.go 프로젝트: GuoBug/beeblog
func (this *CategoryController) Get() {
	this.Data["IsCategory"] = true

	this.Data["IsLogin"] = checkAccount(this.Ctx)
	this.TplNames = "category.html"

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

	switch op {
	case "add":
		name := this.Input().Get("category")
		beego.Debug(name)
		if len(name) == 0 {
			break
		}
		/* 需要在models 里面处理 */
		err := models.AddCategory(name)
		if err != nil {
			beego.Error(err)
		}
		this.Redirect("/category", 302)
		return

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

		err := models.DeleteCategory(id)
		if err != nil {
			beego.Error(err)
		}
		this.Redirect("/category", 302)
		return
	}

	/* 取值分类中的所以列 Categories 在页面中*/
	var err error
	this.Data["Categories"], err = models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}
}
예제 #5
0
파일: category.go 프로젝트: YanGeng/Beeblog
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)
	}
}
예제 #6
0
func (this *CategoryController) Get() {
	op := this.Input().Get("op")
	name := this.Input().Get("name")
	fmt.Println("op value:" + op + " name value:" + name)
	switch op {
	case "add":
		fmt.Println("categoryADD")
		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":
		fmt.Println("categoryDEL")
		id := this.Input().Get("id")
		if len(id) == 0 {
			break
		}
		err := models.DelCategories(id)
		if err != nil {
			beego.Error(err)
		}
		this.Redirect("/category", 301)
		return
	}
	this.Data["IsCategory"] = true
	this.TplName = "category.html"

	var err error
	this.Data["Categories"], err = models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}
}
예제 #7
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)
		}
	}

}