if topic == nil { ctx.ViewData["errorMsg"] = "话题不存在" return ctx.Render("error", nil) } sort := ctx.Get("o") //排序方式 t := ctx.Get("t") //时间范围 ctx.ViewData["Order"] = golink.ORDER_TYPE_HOT if _, ok := golink.ORDER_TYPE_MAP[sort]; ok { ctx.ViewData["Order"] = sort } page, pagesize := utils.PagerParams(ctx.Request) links, _ := models.Link_ForTopic(topic.Id, page, pagesize, sort, t) followers, _ := models.Topic_GetFollowers(topic.Id, 1, 24) ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx) ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE ctx.ViewData["Followers"] = followers return ctx.View(models.Topic_ToVTopic(topic, ctx)) }). //Filters(filters.NewRequireLoginFilter()). // 暂时不需要登陆吧 /** * 关注话题 */ Post("follow", func(ctx *goku.HttpContext) goku.ActionResulter { topicId, _ := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64)
topic, _ := models.Topic_GetByName(topicName) if topic == nil { ctx.ViewData["errorMsg"] = "话题不存在" return ctx.Render("error", nil) } sort := ctx.Get("srt") //排序方式 t := ctx.Get("t") //时间范围 ctx.ViewData["Order"] = "top" if sort == "top" || sort == "hot" || sort == "later" || sort == "vote" { ctx.ViewData["Order"] = sort } links, _ := models.Link_ForTopic(topic.Id, 1, golink.PAGE_SIZE, sort, t) followers, _ := models.Topic_GetFollowers(topic.Id, 1, 12) ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx) ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE ctx.ViewData["Followers"] = followers return ctx.View(models.Topic_ToVTopic(topic, ctx)) }).Filters(filters.NewRequireLoginFilter()). /** * 关注话题 */ Post("follow", func(ctx *goku.HttpContext) goku.ActionResulter { topicId, _ := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64)