码农笔录博客源码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

80 行
1.7 KiB

6 年前
package controllers
import (
"github.com/astaxie/beego"
"beeblog/service"
"beeblog/models"
)
6 年前
type PageController struct {
beego.Controller
}
// @router /iframe/blog [get]
func (this *PageController) Blog() {
cats, err := service.GetCats()
if err != nil {
6 年前
this.Redirect("/404", 302)
return
}
this.Data["Cats"] = cats
6 年前
this.TplName = "iframe/blog.html"
}
// @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
}
// @router /iframe/note [get]
func (this *PageController) IframeNote() {
6 年前
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
}
}
this.TplName = "iframe/note.html"
}
6 年前
// @router /us
func (this *PageController) UsPage() {
this.Data["IsUs"] = true
this.Data["UserId"] = this.GetSession("userid")
this.Data["HeadImg"] = this.GetSession("headimg")
this.Data["NickName"] = this.GetSession("nickname")
this.Data["IsLogin"] = this.GetSession("nickname") != nil
this.TplName = "us.html"
}
6 年前
// @router /404 [get]
func (this *PageController) PageNotFound() {
this.TplName = "404.html"
}
6 年前
// @router /404 [get]
6 年前
func (this *PageController) ServerError() {
this.TplName = "500.html"
}
// @router /403 [get]
func (this *PageController) ServerDemined() {
this.TplName = "403.html"
}