本文整理匯總了Golang中github.com/varding/wetalk/modules/models.Post.Comments方法的典型用法代碼示例。如果您正苦於以下問題:Golang Post.Comments方法的具體用法?Golang Post.Comments怎麽用?Golang Post.Comments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/varding/wetalk/modules/models.Post
的用法示例。
在下文中一共展示了Post.Comments方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PostReplysCount
func PostReplysCount(post *models.Post) {
cnt, err := post.Comments().Count()
if err == nil {
post.Replys = int(cnt)
//disable post editable
post.CanEdit = false
err = post.Update("Replys", "CanEdit")
}
if err != nil {
beego.Error("PostReplysCount ", err)
}
}
示例2: SaveComment
func (form *CommentForm) SaveComment(comment *models.Comment, user *models.User, post *models.Post) error {
comment.Message = form.Message
comment.MessageCache = utils.RenderMarkdown(form.Message)
comment.User = user
comment.Post = post
if err := comment.Insert(); err == nil {
post.LastReply = user
post.Update("LastReply", "LastReplied")
cnt, _ := post.Comments().Filter("Id__lte", comment.Id).Count()
comment.Floor = int(cnt)
return comment.Update("Floor")
} else {
return err
}
}
示例3: loadComments
func (this *PostRouter) loadComments(post *models.Post, comments *[]*models.Comment) {
qs := post.Comments()
if num, err := qs.RelatedSel("User").OrderBy("Id").All(comments); err == nil {
this.Data["Comments"] = *comments
this.Data["CommentsNum"] = num
}
}