Skip to content

Commit f5deccc

Browse files
committed
升级到beego 1.6
1 parent b5b13c2 commit f5deccc

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

app/controllers/base.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (this *BaseController) auth() {
5757

5858
if this.userId == 0 && (this.controllerName != "main" ||
5959
(this.controllerName == "main" && this.actionName != "logout" && this.actionName != "login")) {
60-
this.redirect(beego.UrlFor("MainController.Login"))
60+
this.redirect(beego.URLFor("MainController.Login"))
6161
}
6262
}
6363

@@ -70,7 +70,7 @@ func (this *BaseController) display(tpl ...string) {
7070
tplname = this.controllerName + "/" + this.actionName + ".html"
7171
}
7272
this.Layout = "layout/layout.html"
73-
this.TplNames = tplname
73+
this.TplName = tplname
7474
}
7575

7676
// 重定向
@@ -102,7 +102,7 @@ func (this *BaseController) showMsg(args ...string) {
102102
// 输出json
103103
func (this *BaseController) jsonResult(out interface{}) {
104104
this.Data["json"] = out
105-
this.ServeJson()
105+
this.ServeJSON()
106106
this.StopRun()
107107
}
108108

app/controllers/group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (this *GroupController) List() {
2222

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

app/controllers/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ func (this *MainController) Profile() {
9494
if len(password1) < 6 {
9595
flash.Error("密码长度必须大于6位")
9696
flash.Store(&this.Controller)
97-
this.redirect(beego.UrlFor(".Profile"))
97+
this.redirect(beego.URLFor(".Profile"))
9898
} else if password2 != password1 {
9999
flash.Error("两次输入的密码不一致")
100100
flash.Store(&this.Controller)
101-
this.redirect(beego.UrlFor(".Profile"))
101+
this.redirect(beego.URLFor(".Profile"))
102102
} else {
103103
user.Salt = string(utils.RandomCreateBytes(10))
104104
user.Password = libs.Md5([]byte(password1 + user.Salt))
@@ -107,7 +107,7 @@ func (this *MainController) Profile() {
107107
}
108108
flash.Success("修改成功!")
109109
flash.Store(&this.Controller)
110-
this.redirect(beego.UrlFor(".Profile"))
110+
this.redirect(beego.URLFor(".Profile"))
111111
}
112112

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

149-
this.redirect(beego.UrlFor("TaskController.List"))
149+
this.redirect(beego.URLFor("TaskController.List"))
150150
}
151151
flash.Error(errorMsg)
152152
flash.Store(&this.Controller)
153-
this.redirect(beego.UrlFor("MainController.Login"))
153+
this.redirect(beego.URLFor("MainController.Login"))
154154
}
155155
}
156156

157-
this.TplNames = "main/login.html"
157+
this.TplName = "main/login.html"
158158
}
159159

160160
// 退出登录
161161
func (this *MainController) Logout() {
162162
this.Ctx.SetCookie("auth", "")
163-
this.redirect(beego.UrlFor("MainController.Login"))
163+
this.redirect(beego.URLFor("MainController.Login"))
164164
}
165165

166166
// 获取系统时间

app/controllers/task.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (this *TaskController) List() {
6666
this.Data["list"] = list
6767
this.Data["groups"] = groups
6868
this.Data["groupid"] = groupId
69-
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.UrlFor("TaskController.List", "groupid", groupId), true).ToString()
69+
this.Data["pageBar"] = libs.NewPager(page, int(count), this.pageSize, beego.URLFor("TaskController.List", "groupid", groupId), true).ToString()
7070
this.display()
7171
}
7272

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

@@ -316,7 +316,7 @@ func (this *TaskController) Start() {
316316

317317
refer := this.Ctx.Request.Referer()
318318
if refer == "" {
319-
refer = beego.UrlFor("TaskController.List")
319+
refer = beego.URLFor("TaskController.List")
320320
}
321321
this.redirect(refer)
322322
}
@@ -336,7 +336,7 @@ func (this *TaskController) Pause() {
336336

337337
refer := this.Ctx.Request.Referer()
338338
if refer == "" {
339-
refer = beego.UrlFor("TaskController.List")
339+
refer = beego.URLFor("TaskController.List")
340340
}
341341
this.redirect(refer)
342342
}

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func main() {
1717
jobs.InitJobs()
1818

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

43-
beego.SessionOn = true
43+
beego.BConfig.WebConfig.Session.SessionOn = true
4444
beego.Run()
4545
}

0 commit comments

Comments
 (0)