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

Golang template.Messages类代码示例

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

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



在下文中一共展示了Messages类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: DeleteLatestNews

func DeleteLatestNews(ren render.Render, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	_, err := repository.DeleteLatestNews(db, params["id"])

	if err != nil {
		log.Println(err)
		sessionMessages.AddDanger("Failed to delete news.")
	} else {
		sessionMessages.AddSuccess("Successfully deleted news.")
	}

	ren.Redirect("/latest_news")
}
开发者ID:peteraba,项目名称:go-blah,代码行数:12,代码来源:latest_news.go


示例2: UpdatePlant

func UpdatePlant(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	id, _ := strconv.ParseInt(params["id"], 10, 64)

	plant := entity.NewPlant()

	plant.Populate(getPlantMap(r, params["id"]))

	val, errors := validation.ValidateDefaultEntity(plant, db, PLANT)

	if val {
		_, err := repository.UpdatePlant(plant, db, params["id"])

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to update plant.")
		} else {
			sessionMessages.AddSuccess("Successfully update plant.")

			updatePopularNames(db, id, PLANT, plant.GetPopularNames().GetValues())
			createMedia(r, mediaManager, db, sessionMessages, PLANT, id)
		}

		ren.Redirect("/plant/")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/plant/" + params["id"])
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:31,代码来源:plant.go


示例3: CreatePlant

func CreatePlant(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	plant := entity.NewPlant()

	plant.Populate(getPlantMap(r, ""))

	val, errors := validation.ValidateDefaultEntity(plant, db, PLANT)

	if val {
		res, err := repository.InsertPlant(plant, db)

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to create plant.")
		} else {
			sessionMessages.AddSuccess("Successfully created plant.")

			id, _ := res.LastInsertId()

			insertPopularNames(db, id, PLANT, plant.GetPopularNames().GetValues())
			createMedia(r, mediaManager, db, sessionMessages, PLANT, id)
		}

		ren.Redirect("/plant")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/plant/new")
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:31,代码来源:plant.go


示例4: UpdateComponent

func UpdateComponent(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	id, _ := strconv.ParseInt(params["id"], 10, 64)

	component := entity.NewComponent()

	component.Populate(getComponentMap(r, params["id"]))

	val, errors := validation.ValidateComponent(component, db, COMPONENT)

	if val {
		_, err := repository.UpdateComponent(component, db, params["id"])

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to update component.")
		} else {
			sessionMessages.AddSuccess("Successfully updated component.")

			createMedia(r, mediaManager, db, sessionMessages, COMPONENT, id)
		}

		ren.Redirect("/component")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/component/" + params["id"])
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:30,代码来源:component.go


示例5: CreateComponent

func CreateComponent(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	component := entity.NewComponent()

	component.Populate(getComponentMap(r, ""))

	val, errors := validation.ValidateComponent(component, db, COMPONENT)

	if val {
		res, err := repository.InsertComponent(component, db)

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to create component.")
		} else {
			sessionMessages.AddSuccess("Successfully created component.")

			id, _ := res.LastInsertId()

			createMedia(r, mediaManager, db, sessionMessages, "component", id)
		}

		ren.Redirect("/component")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/component/new")
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:30,代码来源:component.go


示例6: DeleteComponent

func DeleteComponent(ren render.Render, mediaManager *media.Manager, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	var err error

	id, _ := strconv.ParseInt(params["id"], 10, 64)

	media_list := getMediaList(db, COMPONENT, id)

	if media_list != nil {
		_, errors := DeleteEntityMedia(*media_list, mediaManager, db)

		for _, err := range errors {
			log.Println(err)
		}

		_, err = repository.DeleteEntityMedia(db, id, COMPONENT)
		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to delete media for component.")
		}
	}

	_, err = repository.DeleteComponent(db, id)
	if err != nil {
		log.Println(err)
		sessionMessages.AddDanger("Failed to delete component.")
	} else {
		sessionMessages.AddSuccess("Successfully deleted component.")
	}

	ren.Redirect("/component")
}
开发者ID:peteraba,项目名称:go-blah,代码行数:31,代码来源:component.go


示例7: Upload

func (m *Manager) Upload(r *http.Request, sessionMessages *template.Messages, args ...string) map[int]string {
	filenames := make(map[int]string)

	for key, form_key := range args {
		if !m.hasUpload(r, form_key) {
			//sessionMessages.AddInfo(fmt.Sprintf("No file upload for upload field #%d", key+1))
			continue
		}

		file, header, err := r.FormFile(form_key)
		if err != nil {
			sessionMessages.AddDanger(fmt.Sprintf(err.Error()))
		}

		data, err := ioutil.ReadAll(file)
		if err != nil {
			sessionMessages.AddDanger(fmt.Sprintf("Couldn't read uploaded file. #%d", key+1))
			continue
		}

		content_type := header.Header.Get("Content-Type")
		filename := m.getFileName(data)
		extension := m.getExtensionName(content_type)

		for _, uploadHandler := range m.uploadHandlers {
			go uploadHandler.Upload(data, filename, extension, content_type)
		}

		filenames[key] = filename + "." + extension
		sessionMessages.AddSuccess(fmt.Sprintf("File is being uploaded for upload field #%d", key+1))
	}

	return filenames
}
开发者ID:peteraba,项目名称:go-blah,代码行数:34,代码来源:manager.go


示例8: UpdateLatestNews

func UpdateLatestNews(ren render.Render, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	latest_news := entity.NewLatestNews()

	latest_news.Populate(getLatestNewsMap(r))

	val, errors := validation.ValidateLatestNews(latest_news, db, LATEST_NEWS)

	if val {
		_, err := repository.UpdateLatestNews(latest_news, db, params["id"])

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to upload news.")
		} else {
			sessionMessages.AddSuccess("Successfully upload news.")
		}

		ren.Redirect("/latest_news")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/latest_news/" + params["id"])
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:26,代码来源:latest_news.go


示例9: UpdateInvertebrate

func UpdateInvertebrate(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	id, _ := strconv.ParseInt(params["id"], 10, 64)

	invertebrate := entity.NewInvertebrate()

	invertebrate.Populate(getInvertebrateMap(r, params["id"]))

	val, errors := validation.ValidateDefaultEntity(invertebrate, db, INVERTEBRATE)

	if val {
		_, err := repository.UpdateInvertebrate(invertebrate, db, params["id"])

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to upload invertebrate.")
		} else {
			sessionMessages.AddSuccess("Successfully upload invertebrate.")

			updatePopularNames(db, id, INVERTEBRATE, invertebrate.GetPopularNames().GetValues())
			createMedia(r, mediaManager, db, sessionMessages, INVERTEBRATE, id)
		}

		ren.Redirect("/invertebrate")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/invertebrate/" + params["id"])
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:31,代码来源:invertebrate.go


示例10: CreateInvertebrate

func CreateInvertebrate(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	invertebrate := entity.NewInvertebrate()

	invertebrate.Populate(getInvertebrateMap(r, ""))

	val, errors := validation.ValidateDefaultEntity(invertebrate, db, INVERTEBRATE)

	if val {
		res, err := repository.InsertInvertebrate(invertebrate, db)

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to create invertebrate.")
		} else {
			sessionMessages.AddSuccess("Successfully created invertebrate.")

			id, _ := res.LastInsertId()

			insertPopularNames(db, id, INVERTEBRATE, invertebrate.GetPopularNames().GetValues())
			createMedia(r, mediaManager, db, sessionMessages, INVERTEBRATE, id)
		}

		ren.Redirect("/invertebrate")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/invertebrate/new")
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:31,代码来源:invertebrate.go


示例11: UpdateCoral

func UpdateCoral(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	id, _ := strconv.ParseInt(params["id"], 10, 64)

	coral := entity.NewCoral()

	coral.Populate(getCoralMap(r, params["id"]))

	val, errors := validation.ValidateCoral(coral, db, CORAL)

	if val {
		_, err := repository.UpdateCoral(coral, db, params["id"])

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to update coral.")
		} else {
			sessionMessages.AddSuccess("Successfully update coral.")

			updatePopularNames(db, id, CORAL, coral.GetPopularNames().GetValues())
			createMedia(r, mediaManager, db, sessionMessages, CORAL, id)
		}

		ren.Redirect("/coral")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/coral/" + params["id"])
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:31,代码来源:coral.go


示例12: CreateCoral

func CreateCoral(ren render.Render, mediaManager *media.Manager, r *http.Request, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	coral := entity.NewCoral()

	coral.Populate(getCoralMap(r, ""))

	val, errors := validation.ValidateCoral(coral, db, CORAL)

	if val {
		res, err := repository.InsertCoral(coral, db)

		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to create coral.")
		} else {
			sessionMessages.AddSuccess("Successfully created coral.")

			id, _ := res.LastInsertId()

			insertPopularNames(db, id, CORAL, coral.GetPopularNames().GetValues())
			createMedia(r, mediaManager, db, sessionMessages, CORAL, id)
		}

		ren.Redirect("/coral")
	} else {
		for k, msg := range errors {
			sessionMessages.AddDanger(k + ": " + msg)
		}

		ren.Redirect("/coral/new")
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:31,代码来源:coral.go


示例13: DeleteInvertebrate

func DeleteInvertebrate(ren render.Render, mediaManager *media.Manager, db *sql.DB, params martini.Params, sessionMessages *template.Messages) {
	var err error

	id, _ := strconv.ParseInt(params["id"], 10, 64)

	media_list := getMediaList(db, INVERTEBRATE, id)

	if media_list != nil {
		_, errors := DeleteEntityMedia(*media_list, mediaManager, db)

		for _, err := range errors {
			log.Println(err)
		}

		_, err = repository.DeleteEntityMedia(db, id, INVERTEBRATE)
		if err != nil {
			log.Println(err)
			sessionMessages.AddDanger("Failed to delete media for invertebrate.")
		}
	}

	_, err = repository.DeleteEntityNames(db, id, INVERTEBRATE)
	if err != nil {
		log.Println(err)
		sessionMessages.AddDanger("Failed to delete popular names for invertabrate.")
	}

	_, err = repository.DeleteInvertebrate(db, id)
	if err != nil {
		log.Println(err)
		sessionMessages.AddDanger("Failed to delete invertebrate.")
	} else {
		sessionMessages.AddSuccess("Successfully deleted invertebrate.")
	}

	ren.Redirect("/invertebrate")
}
开发者ID:peteraba,项目名称:go-blah,代码行数:37,代码来源:invertebrate.go



注:本文中的github.com/peteraba/go-blah/template.Messages类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang util.NamedDbf类代码示例发布时间:2022-05-28
下一篇:
Golang trace.Frame类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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