本文整理匯總了Golang中github.com/blackmady/NoneCMS/app/models.Article.Save方法的典型用法代碼示例。如果您正苦於以下問題:Golang Article.Save方法的具體用法?Golang Article.Save怎麽用?Golang Article.Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/blackmady/NoneCMS/app/models.Article
的用法示例。
在下文中一共展示了Article.Save方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Add
//.........這裏部分代碼省略.........
description = utils.Html2str(content)
article.Description = utils.Substr(description, Introcude_length)
} else {
article.Description = ""
}
}
var relation string = c.Params.Get("relation")
if len(relation) > 0 {
article.Relation = relation
} else {
article.Relation = ""
}
var pagetype string = c.Params.Get("pagetype")
if len(pagetype) > 0 {
Pagetype, err := strconv.ParseInt(pagetype, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
article.Pagetype = Pagetype
} else {
article.Pagetype = 0
}
var maxcharperpage string = c.Params.Get("maxcharperpage")
if len(maxcharperpage) > 0 {
Maxcharperpage, err := strconv.ParseInt(maxcharperpage, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
article.Maxcharperpage = Maxcharperpage
} else {
article.Maxcharperpage = 10000
}
var istop string = c.Params.Get("istop")
if len(istop) > 0 {
Istop, err := strconv.ParseInt(istop, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
article.Istop = Istop
} else {
article.Istop = 0
}
var status string = c.Params.Get("status")
if len(status) > 0 {
Status, err := strconv.ParseInt(status, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
article.Status = Status
} else {
article.Status = 1
}
var iscomment string = c.Params.Get("iscomment")
if len(iscomment) > 0 {
Iscomment, err := strconv.ParseInt(iscomment, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
article.Iscomment = Iscomment
} else {
article.Status = 1
}
if article.Save() {
if len(dosubmit) > 0 {
c.Flash.Success("添加內容成功!")
c.Flash.Out["url"] = "/Content/list/" + cid + "/"
return c.Redirect("/Message/")
} else if len(dosubmit_continue) > 0 {
c.Flash.Success("添加內容成功!")
c.Flash.Out["url"] = "/Content/add/" + cid + "/"
return c.Redirect("/Message/")
} else {
c.Flash.Success("添加內容成功!")
c.Flash.Out["url"] = "/Content/list/" + cid + "/"
return c.Redirect("/Message/")
}
} else {
c.Flash.Error("添加內容失敗")
c.Flash.Out["url"] = "/Content/add/" + cid + "/"
return c.Redirect("/Message/")
}
}
}
示例2: AddContent
//.........這裏部分代碼省略.........
//內容
article_info := article.GetByCid(Cid)
c.Render(title, cid, category_info, article_info)
return c.RenderTemplate("Content/Manage/AddContent.html")
} else {
c.Render(title, cid)
return c.RenderTemplate("Content/Manage/AddContent.html")
}
} else {
var cid string = c.Params.Get("cid")
if len(cid) < 0 {
c.Flash.Error("請選擇欄目!")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
}
UserID := utils.GetSession("UserID", c.Session)
if len(UserID) > 0 {
UserID, err := strconv.ParseInt(UserID, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
article.Aid = UserID
}
var title string = c.Params.Get("title")
if len(title) > 0 {
article.Title = title
} else {
c.Flash.Error("請輸入標題!")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
}
var style_color string = c.Params.Get("style_color")
article.Color = style_color
var style_font_weight string = c.Params.Get("style_font_weight")
article.Font = style_font_weight
var keywords string = c.Params.Get("keywords")
if len(keywords) > 0 {
article.Keywords = keywords
} else {
article.Keywords = ""
}
var content string = c.Params.Get("content")
if len(content) > 0 {
article.Content = content
} else {
c.Flash.Error("請輸入內容!")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
}
if len(cid) > 0 {
Cid, err := strconv.ParseInt(cid, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
article.Cid = Cid
//內容
article_info := article.GetByCid(Cid)
if article_info.Id > 0 {
if article.Edit(article_info.Id) {
c.Flash.Success("編輯內容成功!")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
} else {
c.Flash.Success("編輯內容成功!")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
}
} else {
if article.Save() {
c.Flash.Success("添加內容成功!")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
} else {
c.Flash.Error("添加內容失敗")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
}
}
} else {
c.Flash.Error("請選擇欄目!")
c.Flash.Out["url"] = "/Content/addContent/" + cid + "/"
return c.Redirect("/Message/")
}
}
}