feat:优化项目空间的显示数量

This commit is contained in:
lifei6671
2018-11-27 11:47:19 +08:00
parent 2460a32ac5
commit b240b85011
4 changed files with 10 additions and 28 deletions

View File

@@ -48,12 +48,4 @@ func (c *HomeController) Index() {
c.Data["TotalPages"] = int(math.Ceil(float64(totalCount) / float64(pageSize)))
c.Data["Lists"] = books
labels, totalCount, err := models.NewLabel().FindToPager(1, 10)
if err != nil {
c.Data["Labels"] = make([]*models.Label, 0)
} else {
c.Data["Labels"] = labels
}
}

View File

@@ -23,9 +23,11 @@ func (c *ItemsetsController) Prepare() {
func (c *ItemsetsController) Index() {
c.Prepare()
c.TplName = "items/index.tpl"
pageSize := 18
pageIndex, _ := c.GetInt("page", 0)
items, totalCount, err := models.NewItemsets().FindToPager(pageIndex, conf.PageSize)
items, totalCount, err := models.NewItemsets().FindToPager(pageIndex, pageSize)
if err != nil && err != orm.ErrNoRows {
c.ShowErrorPage(500, err.Error())
@@ -38,7 +40,7 @@ func (c *ItemsetsController) Index() {
}
if totalCount > 0 {
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
pager := pagination.NewPagination(c.Ctx.Request, totalCount, pageSize, c.BaseUrl())
c.Data["PageHtml"] = pager.HtmlPages()
} else {
c.Data["PageHtml"] = ""
@@ -50,6 +52,7 @@ func (c *ItemsetsController) Index() {
func (c *ItemsetsController) List() {
c.Prepare()
c.TplName = "items/list.tpl"
pageSize := 18
itemKey := c.Ctx.Input.Param(":key")
pageIndex, _ := c.GetInt("page", 1)
@@ -70,13 +73,13 @@ func (c *ItemsetsController) List() {
if c.Member != nil {
memberId = c.Member.MemberId
}
searchResult, totalCount, err := models.NewItemsets().FindItemsetsByItemKey(itemKey, pageIndex, conf.PageSize, memberId)
searchResult, totalCount, err := models.NewItemsets().FindItemsetsByItemKey(itemKey, pageIndex, pageSize, memberId)
if err != nil && err != orm.ErrNoRows {
c.ShowErrorPage(500, "查询文档列表时出错")
}
if totalCount > 0 {
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
pager := pagination.NewPagination(c.Ctx.Request, totalCount, pageSize, c.BaseUrl())
c.Data["PageHtml"] = pager.HtmlPages()
} else {
c.Data["PageHtml"] = ""