本文整理匯總了Golang中github.com/beego/wetalk/modules/models.Comment類的典型用法代碼示例。如果您正苦於以下問題:Golang Comment類的具體用法?Golang Comment怎麽用?Golang Comment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Comment類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetToComment
func (form *CommentAdminForm) SetToComment(comment *models.Comment) {
utils.SetFormValues(form, comment)
if comment.User == nil {
comment.User = &models.User{}
}
comment.User.Id = form.User
if comment.Post == nil {
comment.Post = &models.Post{}
}
comment.Post.Id = form.Post
comment.MessageCache = utils.RenderMarkdown(comment.Message)
}
示例2: Save
// view for new object save
func (this *CommentAdminRouter) Save() {
form := post.CommentAdminForm{Create: true}
if this.ValidFormSets(&form) == false {
return
}
var comment models.Comment
form.SetToComment(&comment)
if err := comment.Insert(); err == nil {
this.FlashRedirect(fmt.Sprintf("/admin/comment/%d", comment.Id), 302, "CreateSuccess")
return
} else {
beego.Error(err)
this.Data["Error"] = err
}
}
示例3: 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
}
}