本文整理汇总了Golang中github.com/go-tango/wego/models.Post.LastAuthorId方法的典型用法代码示例。如果您正苦于以下问题:Golang Post.LastAuthorId方法的具体用法?Golang Post.LastAuthorId怎么用?Golang Post.LastAuthorId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/go-tango/wego/models.Post
的用法示例。
在下文中一共展示了Post.LastAuthorId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdatePost
func (form *PostForm) UpdatePost(post *models.Post, user *models.User) error {
changes := utils.FormChanges(post, form)
if len(changes) == 0 {
return nil
}
utils.SetFormValues(form, post)
post.CategoryId = form.Category
post.TopicId = form.Topic
for _, c := range changes {
if c == "Content" {
post.ContentCache = utils.RenderMarkdown(form.Content)
changes = append(changes, "ContentCache")
}
}
// update last edit author
if post.LastAuthorId != user.Id {
post.LastAuthorId = user.Id
changes = append(changes, "LastAuthor")
}
changes = append(changes, "Updated")
return models.UpdateById(post.Id, post, models.Obj2Table(changes)...)
}
示例2: SetToPost
func (form *PostAdminForm) SetToPost(post *models.Post) {
utils.SetFormValues(form, post)
post.UserId = form.User
post.LastReplyId = form.LastReply
post.LastAuthorId = form.LastAuthor
post.TopicId = form.Topic
//get category
if topic, err := models.GetTopicById(form.Topic); err == nil {
post.CategoryId = topic.CategoryId
}
post.ContentCache = utils.RenderMarkdown(post.Content)
}
示例3: SavePost
func (form *PostForm) SavePost(post *models.Post, user *models.User) error {
utils.SetFormValues(form, post)
post.CategoryId = form.Category
post.TopicId = form.Topic
post.UserId = user.Id
post.LastReplyId = user.Id
post.LastAuthorId = user.Id
post.CanEdit = true
post.ContentCache = utils.RenderMarkdown(form.Content)
// mentioned follow users
FilterMentions(user, post.ContentCache)
return post.Insert()
}