本文整理匯總了Golang中github.com/varding/wetalk/modules/models.Post.User方法的典型用法代碼示例。如果您正苦於以下問題:Golang Post.User方法的具體用法?Golang Post.User怎麽用?Golang Post.User使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/varding/wetalk/modules/models.Post
的用法示例。
在下文中一共展示了Post.User方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetToPost
func (form *PostAdminForm) SetToPost(post *models.Post) {
utils.SetFormValues(form, post)
if post.User == nil {
post.User = &models.User{}
}
post.User.Id = form.User
if post.LastReply == nil {
post.LastReply = &models.User{}
}
post.LastReply.Id = form.LastReply
if post.LastAuthor == nil {
post.LastAuthor = &models.User{}
}
post.LastAuthor.Id = form.LastAuthor
if post.Topic == nil {
post.Topic = &models.Topic{}
}
post.Topic.Id = form.Topic
//get category
topic := &models.Topic{Id: form.Topic}
if err := topic.Read("Id"); err == nil {
if post.Category == nil {
post.Category = &models.Category{}
}
post.Category.Id = topic.Category.Id
}
post.ContentCache = utils.RenderMarkdown(post.Content)
}
示例2: SavePost
func (form *PostForm) SavePost(post *models.Post, user *models.User) error {
utils.SetFormValues(form, post)
post.Category = &models.Category{Id: form.Category}
post.Topic = &models.Topic{Id: form.Topic}
post.User = user
post.LastReply = user
post.LastAuthor = user
post.CanEdit = true
post.ContentCache = utils.RenderMarkdown(form.Content)
// mentioned follow users
FilterMentions(user, post.ContentCache)
return post.Insert()
}