func (c *TopicController) Get() { c.Data["IsTopic"] = true c.Data["IsLogin"] = checkAccount(c.Ctx) op := c.Input().Get("op") switch op { case "del": id := c.Input().Get("id") if len(id) == 0 { break } err := models.DelTopic(id) if err != nil { beego.Error(err) } c.Redirect("/topic", 302) } var err error c.Data["Topics"], err = models.GetAllTopic("", false) if err != nil { beego.Error(err) } c.TplNames = "topic.html" }
func (this *MainController) Get() { fmt.Println("get") this.Data["IsHome"] = true this.TplNames = "index.html" topics, err := models.GetAllTopic(true) if err != nil { beego.Error(err) } this.Data["Topics"] = topics }
func (this *MainController) Get() { this.Data["IsHome"] = true this.TplNames = "index-test.html" q := this.GetString("q") c, _ := strconv.Atoi(this.Input().Get("c")) page, _ := strconv.Atoi(this.Input().Get("p")) if page == 0 { page = 1 } var num int64 if len(q) > 0 { topics, err := models.SearchTopic(q) if err != nil { beego.Error(err) } count, err := models.GetTopicCount(q, int64(c)) if err != nil { beego.Error(err) } num = count this.Data["Topics"] = topics } else { topics, err := models.GetAllTopic(page, int64(c)) if err != nil { beego.Error(err) } count, err := models.GetTopicCount(q, int64(c)) if err != nil { beego.Error(err) } num = count this.Data["Topics"] = topics } classifyCount, err := models.GetClassifyCount() if err != nil { beego.Error(err) } this.Data["classifyCount"] = classifyCount pageNum, _ := beego.AppConfig.Int("pageNum") p := utils.NewPaginator(this.Ctx.Request, pageNum, num) this.Data["paginator"] = p }
func (c *MainController) Get() { c.Data["IsHome"] = true c.TplNames = "home.html" var err error //beego.Debug("cate=", c.Input().Get("cate")) c.Data["Topics"], err = models.GetAllTopic(c.Input().Get("cate"), true) //beego.Debug("date=", c.Data["Topics"].Created) if err != nil { beego.Error(err) } c.Data["IsLogin"] = checkAccount(c.Ctx) categories, err := models.GetAllCategory() if err != nil { beego.Error(err) } c.Data["Categories"] = categories }