码农笔录博客源码
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

77 wiersze
1.7 KiB

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