本文整理汇总了Golang中github.com/astaxie/beego.ReadFromRequest函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadFromRequest函数的具体用法?Golang ReadFromRequest怎么用?Golang ReadFromRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadFromRequest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Write
// 글쓰기 //
func (write *BoardController) Write() {
write.Layout = "admin/layout.html"
write.LayoutSections = make(map[string]string)
write.LayoutSections["Header"] = "board/common/header.html"
write.LayoutSections["Footer"] = "board/common/footer.html"
write.TplNames = "board/write.html"
flash := beego.ReadFromRequest(&write.Controller)
if ok := flash.Data["error"]; ok != "" {
write.Data["flash"] = ok
}
o := orm.NewOrm()
o.Using("default")
board := models.Board{}
if err := write.ParseForm(&board); err != nil {
beego.Error("에러발생 : ", err)
} else {
write.Data["boards"] = board
valid := validation.Validation{}
isValid, _ := valid.Valid(board)
if write.Ctx.Input.Method() == "POST" {
if !isValid {
write.Data["Errors"] = valid.ErrorsMap
beego.Error("폼이 에러")
} else {
searchArticle := models.Board{Idx: board.Idx}
beego.Debug("추가된 게시물 : ", board.Idx)
err = o.Read(&searchArticle)
beego.Debug("Err:", err)
flash := beego.NewFlash()
if err == orm.ErrNoRows || err == orm.ErrMissPK {
beego.Debug("Query 내역 : ", board)
id, err := o.Insert(&board)
if err == nil {
msg := fmt.Sprintf("게시글이 다음과 같은 고유번호로 생성되었다 IDX :", id)
beego.Debug(msg)
flash.Notice(msg)
flash.Store(&write.Controller)
} else {
msg := fmt.Sprintf("다음과 같은 이유로 새로운 게시물을 추가할수 없다. 사유 : ", err)
beego.Debug(msg)
flash.Error(msg)
flash.Store(&write.Controller)
}
// 내용을 Insert후 /board 로 리다이렉트
write.Redirect("/board", 302)
} else {
beego.Debug("Article found matching details supplied. Cannot insert")
}
}
}
}
}
开发者ID:GeoLyu,项目名称:Gopen,代码行数:61,代码来源:board.go
示例2: GetUser
func (this *AdminController) GetUser() {
flash := beego.ReadFromRequest(&this.Controller)
if _, ok := flash.Data["notice"]; ok {
}
badgeCount(this)
o := orm.NewOrm()
o.Using("default")
var users []*models.User
qs := o.QueryTable("User")
num, err := qs.OrderBy("-id").All(&users)
if err != orm.ErrNoRows && num > 0 {
this.Data["users"] = users
} else {
flash.Error("Aucun Utilisateur dans la Base de données")
flash.Store(&this.Controller)
this.Redirect("/incident-manager/admin/user", 302)
}
Template(this, "admin", "user", "Tous les Utilisateurs")
}
开发者ID:kameleon83,项目名称:managIncident,代码行数:27,代码来源:user.go
示例3: Register
// 用户注册页
func (this *UserController) Register() {
beego.ReadFromRequest(&this.Controller)
this.Data["Title"] = "用户注册"
this.TplNames = "register.html"
}
开发者ID:a648132694,项目名称:goblog,代码行数:8,代码来源:user.go
示例4: GetIncident
func (this *AdminController) GetIncident() {
if this.GetSession("role") != "admin" {
this.Redirect("/incident-manager", 302)
}
flash := beego.ReadFromRequest(&this.Controller)
if _, ok := flash.Data["notice"]; ok {
}
badgeCount(this)
r := this.Ctx.Input
fmt.Println("Administrateur avec comme IP : " + r.IP())
o := orm.NewOrm()
o.Using("default")
var incidents []*models.Incident
num, err := o.QueryTable("Incident").OrderBy("-id").RelatedSel().All(&incidents)
if err != orm.ErrNoRows && num > 0 {
this.TplNames = "index/index.tpl"
this.Data["incidents"] = incidents
} else {
// No result
flash.Error("Aucun Incident dans la Base de données")
flash.Store(&this.Controller)
}
Template(this, "index", "index", "Liste incidents")
}
开发者ID:kameleon83,项目名称:managIncident,代码行数:34,代码来源:index.go
示例5: RegisterDemand
func (this *AdminController) RegisterDemand() {
flash := beego.ReadFromRequest(&this.Controller)
if _, ok := flash.Data["notice"]; ok {
}
badgeCount(this)
o := orm.NewOrm()
o.Using("default")
var demand []*models.Register
num, err := o.QueryTable("Register").OrderBy("-id").RelatedSel().All(&demand)
if err != orm.ErrNoRows && num > 0 {
this.TplNames = "admin/register.tpl"
this.Data["demand"] = demand
} else {
// No result
flash.Error("Aucune demande dans la Base de données")
flash.Store(&this.Controller)
this.Redirect("/", 302)
}
Template(this, "admin", "register", "Demande de connexion")
}
开发者ID:kameleon83,项目名称:managIncident,代码行数:28,代码来源:demand.go
示例6: Get
// 首页
func (this *HomeController) Get() {
beego.ReadFromRequest(&this.Controller) //解析flash数据
checkAccountSession(&this.Controller)
this.Data["IsHome"] = true
qs := models.QuerySeter("topic") //获取orm.QuerySeter
// 可以在此处加上查询过滤条件
// qs = qs.Filter("category", "git")
count, _ := models.CountObjects(qs) //查询总记录数
pager := this.SetPaginator(10, count) //设置分页信息页大小、总记录数
qs = qs. /*Filter("category", "git").*/ OrderBy("-created").Limit(10, pager.Offset()).RelatedSel() //执行分页
//var topics []models.Topic 声明一个slice 使用此方式声明的slice在使用的时候若需要取指针的地址需要加取地址&运算符
topics := new([]models.Topic) //该方式创建的topics已经指向指针的地址了,使用该指针的地址时,不需要再加取地址运算符
models.ListObjects(qs, topics) //查询结果带分页
categories := models.GetAllCategory() //查询所有的分类
this.Data["Topics"] = topics
this.Data["Categories"] = categories
this.TplNames = "index.html"
}
开发者ID:a648132694,项目名称:goblog,代码行数:34,代码来源:home.go
示例7: Profile
// 个人信息
func (this *MainController) Profile() {
beego.ReadFromRequest(&this.Controller)
user, _ := models.UserGetById(this.userId)
if this.isPost() {
flash := beego.NewFlash()
user.Email = this.GetString("email")
user.Update()
password1 := this.GetString("password1")
password2 := this.GetString("password2")
if password1 != "" {
if len(password1) < 6 {
flash.Error("密码长度必须大于6位")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
} else if password2 != password1 {
flash.Error("两次输入的密码不一致")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
} else {
user.Salt = string(utils.RandomCreateBytes(10))
user.Password = libs.Md5([]byte(password1 + user.Salt))
user.Update()
}
}
flash.Success("修改成功!")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
}
this.Data["pageTitle"] = "个人信息"
this.Data["user"] = user
this.display()
}
开发者ID:avldya,项目名称:webcron,代码行数:35,代码来源:main.go
示例8: Get
func (this *MainController) Get() {
u := this.GetSession("user")
if u != nil {
usr, ok := u.(m.User)
if ok && usr.UserName != "" {
this.Data[INFO] = SUCCESS
this.Data["user"] = usr
} else {
this.Data[INFO] = DEFAULT
}
} else {
this.Data[INFO] = DEFAULT
}
datas, err := m.GetKindsList()
if err != nil {
}
this.Data["kinds"] = datas
this.Data["status"] = 0
flash := beego.ReadFromRequest(&this.Controller)
if n, ok := flash.Data["notice"]; ok {
this.Data["status"], _ = strconv.Atoi(n)
}
this.TplNames = "index.html"
}
开发者ID:Cheng-Bin,项目名称:GO-BBS,代码行数:28,代码来源:default.go
示例9: View
func (manage *ManageController) View() {
manage.Layout = "basic-layout.tpl"
manage.LayoutSections = make(map[string]string)
manage.LayoutSections["Header"] = "header.tpl"
manage.LayoutSections["Footer"] = "footer.tpl"
manage.TplNames = "manage/view.tpl"
flash := beego.ReadFromRequest(&manage.Controller)
if ok := flash.Data["error"]; ok != "" {
// Display error messages
manage.Data["errors"] = ok
}
if ok := flash.Data["notice"]; ok != "" {
// Display error messages
manage.Data["notices"] = ok
}
o := orm.NewOrm()
o.Using("default")
var articles []*models.Article
num, err := o.QueryTable("articles").All(&articles)
if err != orm.ErrNoRows && num > 0 {
manage.Data["records"] = articles
}
}
开发者ID:dw250100785,项目名称:Learning-Beego,代码行数:29,代码来源:manage.go
示例10: Prepare
func (this *BaseController) Prepare() {
this.controllerName, this.actionName = this.GetControllerAndAction()
this.userSession()
this.flash = beego.ReadFromRequest(&this.Controller)
// load configuration
helpers.LoadConf()
models.LoadAndSetConfig()
this.Data["PageStartTime"] = time.Now()
this.Data["AppName"] = helpers.AppName
this.Data["AppDescription"] = helpers.AppDescription
this.Data["AppKeywords"] = helpers.AppKeywords
this.Data["AppAuthor"] = helpers.AppAuthor
// default layout
this.Layout = helpers.DefaultLayout
// filter users
if app, ok := this.AppController.(AuthPreparer); ok {
app.AuthPrepare()
}
if app, ok := this.AppController.(NestPreparer); ok {
app.NestPrepare()
}
}
开发者ID:Raysmond,项目名称:RaysGo,代码行数:27,代码来源:base.go
示例11: Add
func (manage *ManageController) Add() {
manage.Data["Form"] = &models.Article{}
manage.Layout = "basic-layout.tpl"
manage.LayoutSections = make(map[string]string)
manage.LayoutSections["Header"] = "header.tpl"
manage.LayoutSections["Footer"] = "footer.tpl"
manage.TplNames = "manage/add.tpl"
flash := beego.ReadFromRequest(&manage.Controller)
if ok := flash.Data["error"]; ok != "" {
// Display error messages
manage.Data["flash"] = ok
}
o := orm.NewOrm()
o.Using("default")
article := models.Article{}
if err := manage.ParseForm(&article); err != nil {
beego.Error("Couldn't parse the form. Reason: ", err)
} else {
manage.Data["Articles"] = article
valid := validation.Validation{}
isValid, _ := valid.Valid(article)
if manage.Ctx.Input.Method() == "POST" {
if !isValid {
manage.Data["Errors"] = valid.ErrorsMap
beego.Error("Form didn't validate.")
} else {
searchArticle := models.Article{Name: article.Name}
beego.Debug("Article name supplied:", article.Name)
err = o.Read(&searchArticle)
beego.Debug("Err:", err)
flash := beego.NewFlash()
if err == orm.ErrNoRows || err == orm.ErrMissPK {
beego.Debug("No article found matching details supplied. Attempting to insert article: ", article)
id, err := o.Insert(&article)
if err == nil {
msg := fmt.Sprintf("Article inserted with id:", id)
beego.Debug(msg)
flash.Notice(msg)
flash.Store(&manage.Controller)
} else {
msg := fmt.Sprintf("Couldn't insert new article. Reason: ", err)
beego.Debug(msg)
flash.Error(msg)
flash.Store(&manage.Controller)
}
} else {
beego.Debug("Article found matching details supplied. Cannot insert")
}
}
}
}
}
开发者ID:dw250100785,项目名称:Learning-Beego,代码行数:59,代码来源:manage.go
示例12: Notice
func (this *MainController) Notice() {
this.activeContent("notice")
flash := beego.ReadFromRequest(&this.Controller)
if n, ok := flash.Data["notice"]; ok {
this.Data["notice"] = n
}
}
开发者ID:smagic39,项目名称:klouds,代码行数:8,代码来源:default.go
示例13: Get
func (c *ListController) Get() {
flash := beego.ReadFromRequest(&c.Controller)
if _, err := os.Stat(exepath + "/.config.json"); err != nil {
fmt.Println("erreur Il n'y a pas de config.json")
c.DestroySession()
}
go func() {
t := models.ListFolder{}
t.Folder = listFolder(Root)
WriteJson(t, exepath, "listFolder")
}()
if _, ok := flash.Data["notice"]; ok {
}
if _, ok := flash.Data["error"]; ok {
}
if _, ok := flash.Data["success"]; ok {
}
if _, ok := flash.Data["warning"]; ok {
}
v := c.GetSession("raspDlna")
if v == nil {
c.SetSession("raspDlnaID", int(1))
c.Data["num"] = 0
} else {
c.SetSession("raspDlnaID", v.(int)+1)
c.Data["num"] = v.(int)
}
file := filepath.Clean(c.Ctx.Input.Param(":dir"))
d, _ := Emplacement(Root, file)
l := List(d)
c.Data["title"] = strings.Title("liste")
c.Data["href"] = "/" + file
c.Data["back"] = path.Dir(file)
c.Data["chemin"] = breadcrumb(file)
user, group := MapUidGid()
c.Data["user"] = user
c.Data["group"] = group
sd := SpaceDisk()
reg, _ := regexp.Compile("[^A-Za-z0-9/-]+")
sd1 := strings.Split(reg.ReplaceAllString(sd[1], " "), " ")
c.Data["spacedisk"] = sd1
c.Data["nonLues"], c.Data["numNonLues"] = Nonlues(Root)
c.Data["dirname"] = l
c.Layout = "index.tpl"
c.TplNames = "list.tpl"
}
开发者ID:kameleon83,项目名称:raspDlna,代码行数:58,代码来源:list.go
示例14: Prepare
func (b *Base) Prepare() {
b.Data[`moreStyles`] = &more{}
b.Data[`beforeScripts`] = &more{}
b.Data[`laterScripts`] = &more{}
b.Data["position"] = ``
b.Data[`title`] = ""
beego.ReadFromRequest(&b.Controller)
}
开发者ID:doomsplayer,项目名称:helper,代码行数:9,代码来源:controller.go
示例15: Login
func (this *MainController) Login() {
log.Println("MainController IsLoggedIn", this.IsLoggedIn)
if this.IsLoggedIn {
url := utils.U("home")
this.Redirect(url, 302)
} else {
flash := beego.ReadFromRequest(&this.Controller)
this.Data["flash"] = flash.Data
this.TplNames = "oa/index.tpl"
}
}
开发者ID:sndnvaps,项目名称:gooa,代码行数:11,代码来源:main.go
示例16: ModifyPWD
// 密码找回修改密码页
func (this *UserController) ModifyPWD() {
beego.ReadFromRequest(&this.Controller) //从Request中解析flash数据
flash := beego.NewFlash()
username := this.GetString("username")
uid := this.GetString("uuid")
if username == "" || uid == "" {
flash.Error("非法的请求!")
flash.Store(&this.Controller)
} else {
user := &models.User{
Username: username,
Uuid: uid,
}
//检查是否非法请求
u := models.QueryUserByUsernameAndUUID(username, uid) //根据uuid和用户名查询用户信息
if u != nil {
exprise := u.Exprise //获取过期时间
nowtime := time.Now().Local() //获取当前时间
exprisetime, err := time.Parse("2006-01-02 15:04:05", exprise) //时间字符串转化
if err != nil {
beego.Error("解析时间失败:" + err.Error())
}
//判断链接是否有效
if nowtime.After(exprisetime) { //判断当前时间是否在失效时间之后 为true表示连接已失效
flash.Error("该请求已失效!")
flash.Store(&this.Controller)
}
this.Data["User"] = user
} else {
flash.Error("非法的请求!")
flash.Store(&this.Controller)
}
}
this.Data["Title"] = "密码重置"
this.TplNames = "modify_pwd.html"
return
}
开发者ID:a648132694,项目名称:goblog,代码行数:54,代码来源:user.go
示例17: Get
func (self *Settings) Get() {
self.TplNames = "settings.html"
beego.ReadFromRequest(&self.Controller)
sess_userid, _ := self.GetSession("userid").(int64)
if usr, err := model.GetUser(sess_userid); usr != nil && err == nil {
self.Data["usr"] = *usr
return
}
}
开发者ID:rose312,项目名称:mzr,代码行数:12,代码来源:SettingsHandler.go
示例18: AddUser
// @router /addUser [get]
func (this *MainController) AddUser() {
flash := beego.ReadFromRequest(&this.Controller)
if _, ok := flash.Data["notice"]; ok {
//显示设置成功
this.TplNames = "addUser.html"
} else if _, ok = flash.Data["error"]; ok {
//显示错误
this.TplNames = "addUser.html"
} else {
// 不然默认显示设置页面
this.TplNames = "addUser.html"
}
}
开发者ID:royburns,项目名称:Golearns,代码行数:15,代码来源:default.go
示例19: Login
// user login
func (this *UserController) Login() {
flash := beego.ReadFromRequest(&this.Controller)
username := this.Input().Get("userName")
password := this.Input().Get("password")
if user := m.ValidateUser(username, password); user.UserName != "" {
this.SetSession("user", user)
this.Redirect("/", 302)
} else {
this.Data[INFO] = FAILED
flash.Store(&this.Controller)
flash.Notice("1")
flash.Store(&this.Controller)
this.Redirect("/", 302)
}
}
开发者ID:Cheng-Bin,项目名称:GO-BBS,代码行数:17,代码来源:user.go
示例20: Prepare
func (this *BaseController) Prepare() {
if setting.ConfigBroken {
this.Abort("500")
}
this.checkDeny()
// page start time
this.Data["PageStartTime"] = time.Now()
this.Data["AppName"] = setting.AppName
this.Data["AppVer"] = setting.AppVer
this.Data["PageTitle"] = setting.AppName
// start session
this.StartSession()
//从session中读取登录信息
switch {
// save logined user if exist in session
case this.loginViaSession():
this.IsLogin = true
// save logined user if exist in remember cookie
case this.loginViaRememberCookie():
this.IsLogin = true
}
if this.IsLogin {
this.Data["User"] = &this.User
this.Data["IsLogin"] = this.IsLogin
// if user forbided then do logout
if this.User.IsBanned {
this.LogUserOut()
this.FlashWrite("error", "您的帐号被禁用,无法为您登录!")
this.Redirect("/login", 302)
return
}
}
// read flash message
beego.ReadFromRequest(&this.Controller)
//检查once token,防止表单多次提交
if this.Ctx.Request.Method == "POST" || this.Ctx.Request.Method == "DELETE" || this.Ctx.Request.Method == "PUT" ||
(this.Ctx.Request.Method == "POST" && (this.Ctx.Request.Form.Get("_method") == "delete" || this.Ctx.Request.Form.Get("_method") == "put")) {
this.CheckOnceToken()
}
}
开发者ID:naokij,项目名称:gotalk,代码行数:47,代码来源:base.go
注:本文中的github.com/astaxie/beego.ReadFromRequest函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论