码农笔录博客源码
您最多能選擇 25 個主題 主題必須以字母或數字為開頭,可包含連接號「-」且最長為 35 個字元。

77 行
1.7 KiB

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