码农笔录博客源码
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

77 rindas
1.7 KiB

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