當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FocusCate.Name方法代碼示例

本文整理匯總了Golang中github.com/blackmady/NoneCMS/app/models.FocusCate.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang FocusCate.Name方法的具體用法?Golang FocusCate.Name怎麽用?Golang FocusCate.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/blackmady/NoneCMS/app/models.FocusCate的用法示例。


在下文中一共展示了FocusCate.Name方法的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/")
		}
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:58,代碼來源:focuscate.go

示例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/")
		}

	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:80,代碼來源:focuscate.go


注:本文中的github.com/blackmady/NoneCMS/app/models.FocusCate.Name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。