本文整理汇总了Golang中github.com/beego/wetalk/modules/models.Post.Comments方法的典型用法代码示例。如果您正苦于以下问题:Golang Post.Comments方法的具体用法?Golang Post.Comments怎么用?Golang Post.Comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/beego/wetalk/modules/models.Post
的用法示例。
在下文中一共展示了Post.Comments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PostReplysCount
func PostReplysCount(post *models.Post) {
cnt, err := post.Comments().Count()
if err == nil {
post.Replys = int(cnt)
err = post.Update("Replys")
}
if err != nil {
beego.Error("PostReplysCount ", err)
}
}
示例2: 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)
}
}
示例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
}
}
示例4: 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", "Updated")
cnt, _ := post.Comments().Filter("Id__lte", comment.Id).Count()
comment.Floor = int(cnt)
return comment.Update("Floor")
} else {
return err
}
}