コード例 #1
0
ファイル: topic.go プロジェクト: nashtsai/gorevel
// 帖子详细
func (c Topic) Show(id int64) revel.Result {
	topic := new(models.Topic)
	str := strconv.Itoa(int(id))

	if err := cache.Get("topic"+str, &topic); err != nil {
		has, _ := c.Engine.Id(id).Get(topic)
		if !has {
			return c.NotFound("帖子不存在")
		}
		go cache.Set("topic"+str, topic, cache.FOREVER)
	}

	topic.Hits += 1
	c.Engine.Id(id).Cols("hits").Update(topic)

	replies := c.getReplies(id)

	title := topic.Title
	return c.Render(title, topic, replies)
}