Skip to content

Commit

Permalink
升级到beego 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
lisijie committed Jan 21, 2016
1 parent b5b13c2 commit f5deccc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/controllers/base.go
Expand Up @@ -57,7 +57,7 @@ func (this *BaseController) auth() {

if this.userId == 0 && (this.controllerName != "main" ||
(this.controllerName == "main" && this.actionName != "logout" && this.actionName != "login")) {
this.redirect(beego.UrlFor("MainController.Login"))
this.redirect(beego.URLFor("MainController.Login"))
}
}

Expand All @@ -70,7 +70,7 @@ func (this *BaseController) display(tpl ...string) {
tplname = this.controllerName + "/" + this.actionName + ".html"
}
this.Layout = "layout/layout.html"
this.TplNames = tplname
this.TplName = tplname
}

// 重定向
Expand Down Expand Up @@ -102,7 +102,7 @@ func (this *BaseController) showMsg(args ...string) {
// 输出json
func (this *BaseController) jsonResult(out interface{}) {
this.Data["json"] = out
this.ServeJson()
this.ServeJSON()
this.StopRun()
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/group.go
Expand Up @@ -22,7 +22,7 @@ func (this *GroupController) List() {

this.Data["pageTitle"] = "分组列表"
this.Data["list"] = list
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.UrlFor("GroupController.List"), true).ToString()
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.URLFor("GroupController.List"), true).ToString()
this.display()
}

Expand Down
14 changes: 7 additions & 7 deletions app/controllers/main.go
Expand Up @@ -94,11 +94,11 @@ func (this *MainController) Profile() {
if len(password1) < 6 {
flash.Error("密码长度必须大于6位")
flash.Store(&this.Controller)
this.redirect(beego.UrlFor(".Profile"))
this.redirect(beego.URLFor(".Profile"))
} else if password2 != password1 {
flash.Error("两次输入的密码不一致")
flash.Store(&this.Controller)
this.redirect(beego.UrlFor(".Profile"))
this.redirect(beego.URLFor(".Profile"))
} else {
user.Salt = string(utils.RandomCreateBytes(10))
user.Password = libs.Md5([]byte(password1 + user.Salt))
Expand All @@ -107,7 +107,7 @@ func (this *MainController) Profile() {
}
flash.Success("修改成功!")
flash.Store(&this.Controller)
this.redirect(beego.UrlFor(".Profile"))
this.redirect(beego.URLFor(".Profile"))
}

this.Data["pageTitle"] = "个人信息"
Expand Down Expand Up @@ -146,21 +146,21 @@ func (this *MainController) Login() {
this.Ctx.SetCookie("auth", strconv.Itoa(user.Id)+"|"+authkey)
}

this.redirect(beego.UrlFor("TaskController.List"))
this.redirect(beego.URLFor("TaskController.List"))
}
flash.Error(errorMsg)
flash.Store(&this.Controller)
this.redirect(beego.UrlFor("MainController.Login"))
this.redirect(beego.URLFor("MainController.Login"))
}
}

this.TplNames = "main/login.html"
this.TplName = "main/login.html"
}

// 退出登录
func (this *MainController) Logout() {
this.Ctx.SetCookie("auth", "")
this.redirect(beego.UrlFor("MainController.Login"))
this.redirect(beego.URLFor("MainController.Login"))
}

// 获取系统时间
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/task.go
Expand Up @@ -66,7 +66,7 @@ func (this *TaskController) List() {
this.Data["list"] = list
this.Data["groups"] = groups
this.Data["groupid"] = groupId
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.UrlFor("TaskController.List", "groupid", groupId), true).ToString()
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.URLFor("TaskController.List", "groupid", groupId), true).ToString()
this.display()
}

Expand Down Expand Up @@ -202,7 +202,7 @@ func (this *TaskController) Logs() {
this.Data["pageTitle"] = "任务执行日志"
this.Data["list"] = list
this.Data["task"] = task
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.UrlFor("TaskController.Logs", "id", taskId), true).ToString()
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.URLFor("TaskController.Logs", "id", taskId), true).ToString()
this.display()
}

Expand Down Expand Up @@ -316,7 +316,7 @@ func (this *TaskController) Start() {

refer := this.Ctx.Request.Referer()
if refer == "" {
refer = beego.UrlFor("TaskController.List")
refer = beego.URLFor("TaskController.List")
}
this.redirect(refer)
}
Expand All @@ -336,7 +336,7 @@ func (this *TaskController) Pause() {

refer := this.Ctx.Request.Referer()
if refer == "" {
refer = beego.UrlFor("TaskController.List")
refer = beego.URLFor("TaskController.List")
}
this.redirect(refer)
}
6 changes: 3 additions & 3 deletions main.go
Expand Up @@ -17,8 +17,8 @@ func main() {
jobs.InitJobs()

// 设置默认404页面
beego.Errorhandler("404", func(rw http.ResponseWriter, r *http.Request) {
t, _ := template.New("404.html").ParseFiles(beego.ViewsPath + "/error/404.html")
beego.ErrorHandler("404", func(rw http.ResponseWriter, r *http.Request) {
t, _ := template.New("404.html").ParseFiles(beego.BConfig.WebConfig.ViewsPath + "/error/404.html")
data := make(map[string]interface{})
data["content"] = "page not found"
t.Execute(rw, data)
Expand All @@ -40,6 +40,6 @@ func main() {
beego.AutoRouter(&controllers.TaskController{})
beego.AutoRouter(&controllers.GroupController{})

beego.SessionOn = true
beego.BConfig.WebConfig.Session.SessionOn = true
beego.Run()
}

0 comments on commit f5deccc

Please sign in to comment.