本文整理汇总了Golang中github.com/blackmady/NoneCMS/app/models.FocusCate.Width方法的典型用法代码示例。如果您正苦于以下问题:Golang FocusCate.Width方法的具体用法?Golang FocusCate.Width怎么用?Golang FocusCate.Width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/blackmady/NoneCMS/app/models.FocusCate
的用法示例。
在下文中一共展示了FocusCate.Width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Add
//添加分类
func (c FocusCate) Add(focusCate *models.FocusCate) revel.Result {
if c.Request.Method == "GET" {
title := "添加分类--GoCMS管理系统"
c.Render(title)
return c.RenderTemplate("Content/FocusCate/Add.html")
} else {
var name string = c.Params.Get("name")
if len(name) > 0 {
focusCate.Name = name
} else {
c.Flash.Error("请输入分类名称!")
c.Flash.Out["url"] = "/focusCate/add/"
return c.Redirect("/Message/")
}
var width string = c.Params.Get("width")
if len(width) > 0 {
Width, err := strconv.ParseInt(width, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
focusCate.Width = Width
} else {
c.Flash.Error("请输宽度!")
c.Flash.Out["url"] = "/focusCate/add/"
return c.Redirect("/Message/")
}
var height string = c.Params.Get("height")
if len(height) > 0 {
Height, err := strconv.ParseInt(height, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
focusCate.Height = Height
} else {
c.Flash.Error("请输入高度!")
c.Flash.Out["url"] = "/focusCate/add/"
return c.Redirect("/Message/")
}
if focusCate.Save() {
c.Flash.Success("添加分类成功")
c.Flash.Out["url"] = "/FocusCate/"
return c.Redirect("/Message/")
} else {
c.Flash.Error("添加分类失败!")
c.Flash.Out["url"] = "/FocusCate/add/"
return c.Redirect("/Message/")
}
}
}
示例2: Edit
//编辑分类
func (c FocusCate) Edit(focusCate *models.FocusCate) revel.Result {
if c.Request.Method == "GET" {
title := "编辑分类--GoCMS管理系统"
var id string = c.Params.Get("id")
if len(id) > 0 {
Id, err := strconv.ParseInt(id, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
focusCate_info := focusCate.GetById(Id)
c.Render(title, focusCate_info)
} else {
c.Render(title)
}
return c.RenderTemplate("Content/FocusCate/Edit.html")
} else {
var id string = c.Params.Get("id")
Id, err := strconv.ParseInt(id, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
var name string = c.Params.Get("name")
if len(name) > 0 {
focusCate.Name = name
} else {
c.Flash.Error("请输入分类名称!")
c.Flash.Out["url"] = "/focusCate/edit/" + id + "/"
return c.Redirect("/Message/")
}
var width string = c.Params.Get("width")
if len(width) > 0 {
Width, err := strconv.ParseInt(width, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
focusCate.Width = Width
} else {
c.Flash.Error("请输宽度!")
c.Flash.Out["url"] = "/focusCate/edit/" + id + "/"
return c.Redirect("/Message/")
}
var height string = c.Params.Get("height")
if len(height) > 0 {
Height, err := strconv.ParseInt(height, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
focusCate.Height = Height
} else {
c.Flash.Error("请输入高度!")
c.Flash.Out["url"] = "/focusCate/edit/" + id + "/"
return c.Redirect("/Message/")
}
if focusCate.Edit(Id) {
c.Flash.Success("编辑分类成功")
c.Flash.Out["url"] = "/FocusCate/"
return c.Redirect("/Message/")
} else {
c.Flash.Error("编辑分类失败!")
c.Flash.Out["url"] = "/focusCate/edit/" + id + "/"
return c.Redirect("/Message/")
}
}
}