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("category") lable := this.Input().Get("lable") var err error if len(tid) == 0 { err = models.AddTopic(title, category, lable, content) } else { err = models.ModifyTopic(tid, title, category, lable, content) } if err != nil { beego.Error(err) } this.Redirect("/topic", 302) }
func (this *TopicController) Post() { if !CheckAccount(this.Ctx) { this.Redirect("/login", 302) return } var err error title := this.Input().Get("tname") content := this.Input().Get("tcontent") category := this.Input().Get("category") id := this.Input().Get("id") if len(id) != 0 { err = models.ModifyTopic(id, title, category, content) if err != nil { beego.Error(err) } } else { err = models.AddTopic(title, category, content) if err != nil { beego.Error(err) } } this.Redirect("/topic", 302) }
func (this *TopicController) Post() { if !checkCookie(this.Ctx) { this.Redirect("/login", 302) return } this.Data["isLogin"] = "******" topicName := this.Input().Get("topicName") topicContent := this.Input().Get("topicContent") topicId := this.Input().Get("topicId") category := this.Input().Get("category") labels := this.Input().Get("labels") var err error if len(topicId) == 0 { if len(category) != 0 { err = models.AddTopic(topicName, labels, category, topicContent) } else { this.Redirect("/category", 302) return } } else { err = models.ModifyTopic(topicId, topicName, labels, category, topicContent) } if err != nil { beego.Error(err) } this.Redirect("/topic", 301) return }