Пример #1
0
// 显示文章首页
func (this *ArticleController) Get() {
	//获取类型
	atype := this.Ctx.Input.Param(":type")
	var state []int
	if "trash" != atype {
		state = []int{1}
	} else {
		state = []int{0}
	}

	// 处理分页
	pageSize, err := beego.AppConfig.Int("pagesize")
	if err != nil {
		pageSize = 10
	}
	count, err := models.GetArticleCount(state)
	if err != nil {
		beego.Error(err)
	}
	paginator := pagination.NewPaginator(this.Ctx.Request, pageSize, count)
	this.Data["paginator"] = paginator

	// 查询数据库
	this.Data["Articles"], err = models.GetArticles(paginator.Offset(), pageSize, state)
	if err != nil {
		beego.Error(err)
	}
	this.Data["IsTrash"] = atype == "trash"
	this.Data["Title"] = "管理后台 - 所有文章"
	this.Layout = "manager/layout.html"
	this.TplNames = "manager/article_index.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["HtmlHead"] = "manager/article_index_heade.html"
	return
}
Пример #2
0
Файл: index.go Проект: ruoL/code
//博客首页
func (this *IndexController) Get() {
	//先处理分页
	pageSize, err := beego.AppConfig.Int("pagesize")
	if err != nil {
		beego.Error(err)
	}
	count, err := models.GetArticleCount([]int{1})
	if err != nil {
		beego.Error(err)
	}
	paginator := pagination.NewPaginator(this.Ctx.Request, pageSize, count)
	this.Data["paginator"] = paginator

	this.Data["Articles"], err = models.GetArticles(paginator.Offset(), pageSize, []int{1})
	if err != nil {
		beego.Error(err)
	}
	this.Data["Categories"], err = models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}
	this.Layout = "index/layout.html"
	this.TplNames = "index/index.html"
	return
}
Пример #3
0
//显示后台首页
func (this *WelcomeController) Get() {
	var err error
	this.Data["ArticleCount"], err = models.GetArticleCount([]int{0, 1})
	if err != nil {
		beego.Error(err)
	}
	this.Data["CategoryCount"], err = models.GetCategoryCount()
	if err != nil {
		beego.Error(err)
	}
	this.Data["UserCount"], err = models.GetUserCount()
	if err != nil {
		beego.Error(err)
	}
	this.Data["Title"] = "梵响 - 后台首页"
	this.Layout = "manager/layout.html"
	this.TplNames = "manager/index.html"
}
Пример #4
0
Файл: main.go Проект: ruoL/code
func GetArticleTrashCount() int64 {
	count, _ := models.GetArticleCount([]int{0})
	return count
}