Esempio n. 1
0
// 获取当个话题详情.
func (c *Topic) GetDetail(id int64) *models.Topic {
	var topic models.Topic
	attachModule := NewAttach(c.Db)
	userModule := NewUser(c.Db)

	c.Db.SelectOne(&topic, "select * from topic where topic_id=? limit 1", id)

	// 获取背景图片.
	attach := attachModule.GetOneAttach(topic.BgId)
	topic.Background, _ = attachModule.GetAttachUrl(attach)

	// 获取用户名
	user := userModule.GetById(topic.UserId)
	topic.Author = user.Username

	return &topic
}