码农笔录博客源码
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

77 строки
1.7 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
6 лет назад
this.Data["NoteColl"] = []string{}
6 лет назад
}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
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"
}