• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang models.FocusCate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/blackmady/NoneCMS/app/models.FocusCate的典型用法代码示例。如果您正苦于以下问题:Golang FocusCate类的具体用法?Golang FocusCate怎么用?Golang FocusCate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FocusCate类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:27,代码来源:focus.go


示例2: 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


示例3: Delete

//删除分类
func (c FocusCate) Delete(focusCate *models.FocusCate) revel.Result {

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

	data := make(map[string]string)

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

	if focusCate.DelByID(Id) {
		data["status"] = "1"
		data["message"] = "删除成功!"
		return c.RenderJson(data)
	} else {
		data["status"] = "0"
		data["message"] = "删除失败!"
		return c.RenderJson(data)
	}

}
开发者ID:blackmady,项目名称:GoCMS,代码行数:23,代码来源:focuscate.go


示例4: Index

func (c FocusCate) Index(focusCate *models.FocusCate) revel.Result {

	title := "焦点图分类--GoCMS管理系统"

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

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

		focusCate_list, pages := focusCate.GetByAll(Page, 10)

		c.Render(title, focusCate_list, pages)
	} else {
		focusCate_list, pages := focusCate.GetByAll(1, 10)

		c.Render(title, focusCate_list, pages)
	}

	return c.RenderTemplate("Content/FocusCate/Index.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:23,代码来源:focuscate.go


示例5: 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)

//.........这里部分代码省略.........
开发者ID:blackmady,项目名称:GoCMS,代码行数:101,代码来源:focus.go


示例6: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang models.Logs类代码示例发布时间:2022-05-24
下一篇:
Golang models.Category类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap