码农笔录博客源码
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 години
package controllers
преди 6 години
import (
"github.com/astaxie/beego"
"beeblog/service"
преди 6 години
"beeblog/models"
преди 6 години
)
преди 6 години
type PageController struct {
beego.Controller
}
func (this *PageController) Blog() {
преди 6 години
catService := service.CategoryService{}
cats, err := catService.GetCats()
преди 6 години
if err != nil {
преди 6 години
this.Redirect("/404", 302)
преди 6 години
return
}
this.Data["Cats"] = cats
преди 6 години
this.TplName = "iframe/blog.html"
}
преди 6 години
преди 6 години
func (this *PageController) IframeUser() {
преди 6 години
userService := service.UserService{}
преди 6 години
uid := this.GetSession("userid")
if uid == nil {
this.Data["IsLogin"] = false
} else {
this.Data["IsLogin"] = true
преди 6 години
if user, err := userService.GetUser(uid.(int64)); err == nil {
преди 6 години
this.Data["User"] = user
} else {
this.Data["User"] = &models.User{Id: uid.(int64)}
}
}
this.TplName = "iframe/user.html"
return
}
преди 6 години
func (this *PageController) IframeNote() {
преди 6 години
noteService := service.NoteService{}
преди 6 години
uid := this.GetSession("userid")
if uid == nil {
this.Data["IsLogin"] = false
}else {
this.Data["IsLogin"] = true
преди 6 години
noteColls,err:=noteService.GetNoteColl(uid.(int64))
преди 6 години
if err== nil {
this.Data["NoteColl"] = noteColls
}
}
преди 6 години
this.TplName = "iframe/note.html"
}
преди 6 години
преди 6 години
func (this *PageController) UsPage() {
this.Data["IsUs"] = true
преди 6 години
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 години
this.TplName = "us.html"
}
преди 6 години
func (this *PageController) PageNotFound() {
this.TplName = "404.html"
}
func (this *PageController) ServerError() {
this.TplName = "500.html"
}
преди 6 години
func (this *PageController) ServerDemined() {
this.TplName = "403.html"
}