码农笔录博客源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.5 KiB

6 years ago
package controllers
import (
"github.com/astaxie/beego"
"beeblog/service"
6 years ago
"beeblog/models"
)
6 years ago
type PageController struct {
beego.Controller
}
// @router /iframe/blog [get]
func (this *PageController) Blog() {
cats, err := service.GetCats()
if err != nil {
6 years ago
this.Redirect("/500", 302)
return
}
this.Data["Cats"] = cats
6 years ago
this.TplName = "iframe/blog.html"
}
6 years ago
6 years ago
// @router /iframe/user [get]
func (this *PageController) IframeUser() {
uid := this.GetSession("userid")
if uid == nil {
this.Data["IsLogin"] = false
} else {
this.Data["IsLogin"] = true
if user, err := service.GetUser(uid.(int64)); err == nil {
this.Data["User"] = user
} else {
this.Data["User"] = &models.User{Id: uid.(int64)}
}
}
this.TplName = "iframe/user.html"
return
}
6 years ago
// @router /iframe/note [get]
func (this *PageController) IframeNote() {
6 years ago
uid := this.GetSession("userid")
if uid == nil {
this.Data["IsLogin"] = false
}else {
this.Data["IsLogin"] = true
noteColls,err:=service.GetNoteColl(uid.(int64))
if err== nil {
this.Data["NoteColl"] = noteColls
}
}
6 years ago
this.TplName = "iframe/note.html"
}
6 years ago
6 years ago
// @router /us
func (this *PageController) UsPage() {
this.Data["IsUs"] = true
this.TplName = "us.html"
}
6 years ago
// @router /404 [get]
func (this *PageController) PageNotFound() {
this.TplName = "404.html"
}
// @router /500 [get]
func (this *PageController) ServerError() {
this.TplName = "500.html"
}
6 years ago
// @router /403 [get]
func (this *PageController) ServerDemined() {
this.TplName = "403.html"
}