码农笔录博客源码
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.6 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
}
func (this *PageController) Blog() {
6 years ago
catService := service.CategoryService{}
cats, err := catService.GetCats()
if err != nil {
6 years ago
this.Redirect("/404", 302)
return
}
this.Data["Cats"] = cats
6 years ago
this.TplName = "iframe/blog.html"
}
6 years ago
6 years ago
func (this *PageController) IframeUser() {
6 years ago
userService := service.UserService{}
6 years ago
uid := this.GetSession("userid")
if uid == nil {
this.Data["IsLogin"] = false
} else {
this.Data["IsLogin"] = true
6 years ago
if user, err := userService.GetUser(uid.(int64)); err == nil {
6 years ago
this.Data["User"] = user
} else {
this.Data["User"] = &models.User{Id: uid.(int64)}
}
}
this.TplName = "iframe/user.html"
return
}
6 years ago
func (this *PageController) IframeNote() {
6 years ago
noteService := service.NoteService{}
6 years ago
uid := this.GetSession("userid")
if uid == nil {
this.Data["IsLogin"] = false
}else {
this.Data["IsLogin"] = true
6 years ago
noteColls,err:=noteService.GetNoteColl(uid.(int64))
6 years ago
if err== nil {
this.Data["NoteColl"] = noteColls
}
}
6 years ago
this.TplName = "iframe/note.html"
}
6 years ago
6 years ago
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
6 years ago
this.TplName = "us.html"
}
6 years ago
func (this *PageController) PageNotFound() {
this.TplName = "404.html"
}
func (this *PageController) ServerError() {
this.TplName = "500.html"
}
6 years ago
func (this *PageController) ServerDemined() {
this.TplName = "403.html"
}