Пример #1
0
func (this *TopicController) Post() {
	if !checkAccount(this.Ctx) {
		this.Redirect("/login", 302)
		return
	}

	tId := this.Input().Get("tid")
	title := this.Input().Get("title")
	content := this.Input().Get("content")
	category := this.Input().Get("cate")

	if "" != tId {
		err := models.ModifyTopic(tId, title, content)
		if err != nil {
			beego.Error(err)
			this.Redirect("/", 302)
			return
		}
	} else {
		err := models.AddTopic(title, content, category)
		if err != nil {
			beego.Error(err)
			this.Redirect("/", 302)
			return
		}
	}
	this.Redirect("/topic", 302)
}
Пример #2
0
func (this *TopicController) Post() {
	title := this.Input().Get("title")
	content := this.Input().Get("content")
	classID, _ := strconv.Atoi(this.Input().Get("classID"))

	_, err := models.AddTopic(title, content, int64(classID))
	if err != nil {
		beego.Error(err)
	}
	this.Redirect("/admin/topics", 302)
}
Пример #3
0
Файл: topic.go Проект: lcbyz/Go
func (this *TopicController) Post() {
	title := this.Input().Get("title")
	content := this.Input().Get("content")

	err := models.AddTopic(title, content)
	if err != nil {
		beego.Error(err)
	}

	this.Redirect("/", 302)
}
Пример #4
0
func (this *TopicController) Post() {
	if !checkAccount(this.Ctx) {
		this.Redirect("/login", 302)
		return
	}
	tid := this.Input().Get("tid")
	title := this.Input().Get("title")
	content := this.Input().Get("content")
	label := this.Input().Get("label")
	category := this.Input().Get("category")

	if len(tid) != 0 {
		var err error
		beego.Debug("modify", title, content, label, category)
		err = models.ModifyTopic(tid, title, category, label, content)
		if err != nil {
			beego.Debug(err)
			this.Redirect("/topic", 302)
			return
		}
		this.Redirect("/topic", 302)

	} else {
		op := this.Input().Get("op")
		switch op {
		case "add":
			title := this.Input().Get("title")
			content := this.Input().Get("content")
			category := this.Input().Get("category")
			var err error
			err = models.AddTopic(title, category, label, content)
			if err != nil {
				return
			}
			this.Redirect("/topic", 302)
		case "del":
			id := this.Input().Get("id")
			if len(id) == 0 {
				break
			}

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

}