func (c *TopicController) Get() { c.TplNames = "topic.html" c.Data["IsLogin"] = checkAccount(c.Ctx) c.Data["IsTopic"] = true account := fmt.Sprintf("%v", c.GetSession("account")) name, _ := models.GetUserName(account) topics := make([]*models.StoneTopic, 0) var err error if len(name) == 0 { // c.Redirect("/login?exit=true", 302) c.Data["Name"] = "游客" topics, err = models.GetAllTopics(false, "") if err != nil { beego.Error(err) c.Redirect("/", 301) return } } else { c.Data["Name"] = name topics, err = models.GetAllTopics(false, account) if err != nil { beego.Error(err) c.Redirect("/", 301) return } } c.Data["Topics"] = topics }
func (c *MainController) Get() { c.Data["IsHome"] = true c.TplNames = "home.html" c.Data["IsLogin"] = checkAccount(c.Ctx) // c.Data["IsLogin"] = pass topics, err := models.GetAllTopics(true, "") if err != nil { beego.Error(err) return } account := fmt.Sprintf("%v", c.GetSession("account")) name, _ := models.GetUserName(account) if len(name) == 0 { name = "游客" } c.Data["Name"] = name c.Data["Topics"] = topics }