本文整理匯總了Golang中github.com/blackmady/NoneCMS/app/models.FocusCate.GetCateList方法的典型用法代碼示例。如果您正苦於以下問題:Golang FocusCate.GetCateList方法的具體用法?Golang FocusCate.GetCateList怎麽用?Golang FocusCate.GetCateList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/blackmady/NoneCMS/app/models.FocusCate
的用法示例。
在下文中一共展示了FocusCate.GetCateList方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Index
func (c Focus) Index(focus *models.Focus) revel.Result {
title := "焦點圖列表--GoCMS管理係統"
var page string = c.Params.Get("page")
var search string = c.Params.Get("search")
FocusCate := new(models.FocusCate)
Cate_list := FocusCate.GetCateList()
if len(page) > 0 {
Page, err := strconv.ParseInt(page, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
focus_list, pages, where := focus.GetByAll(search, Page, 10)
c.Render(title, focus_list, Cate_list, where, pages)
} else {
focus_list, pages, where := focus.GetByAll(search, 1, 10)
c.Render(title, focus_list, Cate_list, where, pages)
}
return c.RenderTemplate("Content/Focus/Index.html")
}
示例2: Add
//添加焦點圖
func (c Focus) Add(focus *models.Focus) revel.Result {
if c.Request.Method == "GET" {
title := "添加焦點圖--GoCMS管理係統"
FocusCate := new(models.FocusCate)
Cate_list := FocusCate.GetCateList()
c.Render(title, Cate_list)
return c.RenderTemplate("Content/Focus/Add.html")
} else {
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)
}
focus.Cid = Cid
focusCate := new(models.FocusCate)
focusCate_info := focusCate.GetById(Cid)
if focusCate_info.Id <= 0 {
c.Flash.Error("焦點圖分類錯誤!")
c.Flash.Out["url"] = "/Focus/Add/"
return c.Redirect("/Message/")
}
//****************************************
//圖片
//判斷是否是係統的分隔符
separator := "/"
if os.IsPathSeparator('\\') {
separator = "\\"
} else {
separator = "/"
}
//接收上傳文件
imgFile, header, err := c.Request.FormFile("img")
if err != nil {
c.Flash.Error("圖片上傳錯誤!")
c.Flash.Out["url"] = "/Focus/Add/"
return c.Redirect("/Message/")
}
defer imgFile.Close()
//讀取文件數據
fileData, _ := ioutil.ReadAll(imgFile)
if len(fileData) >= 1024*1024*2 {
c.Flash.Error("你上傳大小為" + utils.FileSize(len(fileData)) + ",文件應小於2M!")
c.Flash.Out["url"] = "/Focus/Add/"
return c.Redirect("/Message/")
}
basepath, _ := filepath.Abs("")
config_file := (revel.BasePath + "/conf/config.conf")
config_file = strings.Replace(config_file, "/", separator, -1)
config_conf, _ := config.ReadDefault(config_file)
//上傳文件目錄
upload_dir, _ := config_conf.String("upload", "upload.dir")
//允許上傳的後綴名
titlesuffix, _ := config_conf.String("upload", "upload.titlesuffix")
//文件類型檢測
if !strings.Contains(titlesuffix, path.Ext(header.Filename)) {
c.Flash.Error("文件隻支持圖片!")
c.Flash.Out["url"] = "/Focus/Add/"
return c.Redirect("/Message/")
}
//前台網站調用目錄
web_save_path := fmt.Sprintf("/%s/focus/%s", upload_dir, time.Now().Format("2006/01/02/"))
//文件保存目錄
save_path := fmt.Sprintf("%s/www/%s/focus/%s", basepath, upload_dir, time.Now().Format("2006/01/02/"))
//字符串替換 /替換為係統分隔符
save_path = strings.Replace(save_path, "/", separator, -1)
//創建目錄
err = os.MkdirAll(save_path, os.ModePerm)
if err != nil {
c.Flash.Error("創建目錄失敗!")
c.Flash.Out["url"] = "/Focus/Add/"
return c.Redirect("/Message/")
}
//新文件名
rand.Seed(time.Now().UnixNano())
rand_num := rand.Intn(99999)
//.........這裏部分代碼省略.........