本文整理汇总了Golang中github.com/beego/wetalk/modules/models.Post.Category方法的典型用法代码示例。如果您正苦于以下问题:Golang Post.Category方法的具体用法?Golang Post.Category怎么用?Golang Post.Category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/beego/wetalk/modules/models.Post
的用法示例。
在下文中一共展示了Post.Category方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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
if post.Category == nil {
post.Category = &models.Category{}
}
post.Category.Id = form.Category
post.ContentCache = utils.RenderMarkdown(post.Content)
}
示例3: 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.ContentCache = utils.RenderMarkdown(form.Content)
// mentioned follow users
FilterMentions(user, post.ContentCache)
return post.Insert()
}