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


Golang models.Category類代碼示例

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


在下文中一共展示了Category類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: List

//內容管理列表
func (c Content) List(article *models.Article) revel.Result {

	title := "內容--GoCMS管理內容"

	var cid string = c.Params.Get("cid")
	var page string = c.Params.Get("page")
	var search string = c.Params.Get("search")

	Cid, err := strconv.ParseInt(cid, 10, 64)
	if err != nil {
		revel.WARN.Println(err)
	}

	category := new(models.Category)
	categorys := category.GetCateGoryOptionHtml(0)

	if len(page) > 0 {
		Page, err := strconv.ParseInt(page, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		article_list, pages, where := article.GetByAll(search, Cid, Page, 10)

		c.Render(title, cid, categorys, article_list, where, pages)
	} else {
		article_list, pages, where := article.GetByAll(search, Cid, 1, 10)

		c.Render(title, cid, categorys, article_list, where, pages)
	}

	return c.RenderTemplate("Content/Manage/Index.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:34,代碼來源:content.go

示例2: Relationlist

//添加相關文章
func (c Content) Relationlist(article *models.Article) revel.Result {
	title := "內容--添加相關文章"

	var page string = c.Params.Get("page")
	var cid string = c.Params.Get("cid")
	var search string = c.Params.Get("search")

	//欄目信息
	category := new(models.Category)
	category_info := category.GetCateGoryOptionHtml(0)

	var Page int64 = 1

	if len(page) > 0 {
		Page, _ = strconv.ParseInt(page, 10, 64)
	}

	Cid, err := strconv.ParseInt(cid, 10, 64)
	if err != nil {
		revel.WARN.Println(err)
	}

	article_list, pages, where := article.GetByList(Cid, search, Page, 10)

	c.Render(title, cid, category_info, article_list, pages, where)
	return c.RenderTemplate("Content/Manage/Relationlist.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:28,代碼來源:content.go

示例3: Left

//左側菜單
func (c Content) Left(article *models.Article) revel.Result {
	title := "左側菜單--GoCMS管理係統"

	category := new(models.Category)
	categorys := category.GetLeftTree()

	c.Render(title, categorys)
	return c.RenderTemplate("Content/Left.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:10,代碼來源:content.go

示例4: CateNameSearch

//快速進入 搜索
func (c Content) CateNameSearch(category *models.Category) revel.Result {
	var catename string = c.Params.Get("catename")

	if len(catename) < 0 {
		return c.RenderHtml("")
	}

	data := category.GetCateNameHtml(catename)

	return c.RenderHtml(data)
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:12,代碼來源:content.go

示例5: Delete

//刪除欄目
func (c Category) Delete(category *models.Category) revel.Result {
	var id string = c.Params.Get("id")

	data := make(map[string]string)

	if len(id) <= 0 {
		data["status"] = "0"
		data["message"] = "參數錯誤!"
	}

	Id, err := strconv.ParseInt(id, 10, 64)
	if err != nil {
		revel.WARN.Println(err)
	}

	if category.DelByID(Id) {

		//******************************************
		//管理員日誌
		if UserID, ok := c.Session["UserID"]; ok {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			logs := new(models.Logs)
			desc := "刪除欄目|^|ID:" + id
			logs.Save(admin_info, c.Controller, desc)
		}
		//*****************************************

		data["status"] = "1"
		data["message"] = "刪除成功!"
	} else {
		data["status"] = "0"
		data["message"] = "刪除失敗!"
	}

	return c.RenderJson(data)
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:44,代碼來源:category.go

示例6: Index

func (c Category) Index(category *models.Category) revel.Result {
	title := "欄目管理--GoCMS管理係統"

	UserID := utils.GetSession("UserID", c.Session)

	if len(UserID) > 0 {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		categorys := category.GetCateGoryHtml(admin_info)

		c.Render(title, categorys)
	} else {
		c.Render(title)
	}

	return c.RenderTemplate("Content/Category/Index.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:23,代碼來源:category.go

示例7: Edit

//編輯內容
func (c Content) Edit(article *models.Article) revel.Result {

	if c.Request.Method == "GET" {
		title := "內容--GoCMS編輯內容"

		var cid string = c.Params.Get("cid")
		var id string = c.Params.Get("id")

		if len(cid) > 0 {

			Cid, err := strconv.ParseInt(cid, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			Id, err := strconv.ParseInt(id, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			//內容
			article_info := article.GetById(Id)

			//欄目信息
			category := new(models.Category)
			category_info := category.GetById(Cid)

			//來源
			copyfrom := new(models.Copyfrom)
			copyfrom_list := copyfrom.GetRoleList()

			c.Render(title, cid, category_info, article_info, copyfrom_list)
			return c.RenderTemplate("Content/Manage/Edit.html")
		} else {
			c.Render(title, cid)
			return c.RenderTemplate("Content/Manage/Edit.html")
		}

	} else {

		var dosubmit string = c.Params.Get("dosubmit")
		var dosubmit_continue string = c.Params.Get("dosubmit_continue")

		var cid string = c.Params.Get("cid")
		var id string = c.Params.Get("id")

		Id, err := strconv.ParseInt(id, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		var title string = c.Params.Get("title")
		if len(title) > 0 {
			article.Title = title
		} else {
			c.Flash.Error("請輸入標題!")
			c.Flash.Out["url"] = "/Content/Add/" + 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 thumb string = c.Params.Get("thumb")
		if len(thumb) > 0 {

			//判斷是否是係統的分隔符
			separator := "/"
			if os.IsPathSeparator('\\') {
				separator = "\\"
			} else {
				separator = "/"
			}

			config_file := (revel.BasePath + "/conf/config.conf")
			config_file = strings.Replace(config_file, "/", separator, -1)
			config_conf, _ := config.ReadDefault(config_file)

			//前台網站地址
			sitedomain, _ := config_conf.String("website", "website.sitedomain")
			thumb = strings.Replace(thumb, sitedomain, "", -1)

			article.Thumb = thumb
		} else {
			article.Thumb = ""
		}

		var content string = c.Params.Get("content")
		if len(content) > 0 {
			article.Content = content
		} else {
			c.Flash.Error("請輸入內容!")
			c.Flash.Out["url"] = "/Content/Add/" + cid + "/"
			return c.Redirect("/Message/")
		}

		var copyfrom string = c.Params.Get("copyfrom")
//.........這裏部分代碼省略.........
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:content.go

示例8: AddContent

//單頁麵 添加內容
func (c Content) AddContent(article *models.Article) revel.Result {
	if c.Request.Method == "GET" {
		title := "內容--GoCMS添加內容"

		var cid string = c.Params.Get("cid")

		if len(cid) > 0 {

			Cid, err := strconv.ParseInt(cid, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			//欄目信息
			category := new(models.Category)
			category_info := category.GetById(Cid)

			//內容
			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 {
//.........這裏部分代碼省略.........
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:content.go

示例9: Add

//添加欄目
func (c Category) Add(category *models.Category) 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)
			}

			//返回菜單Option的HTML
			categorys := category.GetCateGoryOptionHtml(Id)

			c.Render(title, categorys, Id)
		} else {
			//返回菜單Option的HTML
			categorys := category.GetCateGoryOptionHtml(0)
			c.Render(title, categorys)
		}

		return c.RenderTemplate("Content/Category/Add.html")
	} else {

		//欄目類型
		var cate_type string = c.Params.Get("type")
		if len(cate_type) > 0 {
			Type, err := strconv.ParseInt(cate_type, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			category.Type = Type
		} else {
			c.Flash.Error("請選擇欄目類型!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//上級欄目
		var pid string = c.Params.Get("pid")
		if len(pid) > 0 {
			Pid, err := strconv.ParseInt(pid, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			category.Pid = Pid
		} else {
			c.Flash.Error("請選擇父欄目!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//欄目名稱
		var name string = c.Params.Get("name")
		if len(name) > 0 {
			category.Name = name
		} else {
			c.Flash.Error("請輸入欄目名稱!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		var enname string = c.Params.Get("enname")
		if len(enname) > 0 {
			category.Enname = enname
		} else {
			c.Flash.Error("請輸入英文欄目名稱!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//欄目地址
		var url string = c.Params.Get("url")
		if len(url) > 0 {
			category.Url = url
		} else {
			c.Flash.Error("請輸入欄目地址!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//描述
		var desc string = c.Params.Get("desc")
		if len(desc) > 0 {
			category.Desc = desc
		} else {
			c.Flash.Error("請輸入描述!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//是否在導航顯示
		var ismenu string = c.Params.Get("ismenu")
		if len(ismenu) > 0 {
			IsMenu, err := strconv.ParseInt(ismenu, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
//.........這裏部分代碼省略.........
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:category.go


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