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

76 рядки
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
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"
}