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

pull/425/head
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["TotalPages"] = int(math.Ceil(float64(totalCount) / float64(pageSize)))
c.Data["Lists"] = books 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() { func (c *ItemsetsController) Index() {
c.Prepare() c.Prepare()
c.TplName = "items/index.tpl" c.TplName = "items/index.tpl"
pageSize := 18
pageIndex, _ := c.GetInt("page", 0) 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 { if err != nil && err != orm.ErrNoRows {
c.ShowErrorPage(500, err.Error()) c.ShowErrorPage(500, err.Error())
@ -38,7 +40,7 @@ func (c *ItemsetsController) Index() {
} }
if totalCount > 0 { 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() c.Data["PageHtml"] = pager.HtmlPages()
} else { } else {
c.Data["PageHtml"] = "" c.Data["PageHtml"] = ""
@ -50,6 +52,7 @@ func (c *ItemsetsController) Index() {
func (c *ItemsetsController) List() { func (c *ItemsetsController) List() {
c.Prepare() c.Prepare()
c.TplName = "items/list.tpl" c.TplName = "items/list.tpl"
pageSize := 18
itemKey := c.Ctx.Input.Param(":key") itemKey := c.Ctx.Input.Param(":key")
pageIndex, _ := c.GetInt("page", 1) pageIndex, _ := c.GetInt("page", 1)
@ -70,13 +73,13 @@ func (c *ItemsetsController) List() {
if c.Member != nil { if c.Member != nil {
memberId = c.Member.MemberId 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 { if err != nil && err != orm.ErrNoRows {
c.ShowErrorPage(500, "查询文档列表时出错") c.ShowErrorPage(500, "查询文档列表时出错")
} }
if totalCount > 0 { 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() c.Data["PageHtml"] = pager.HtmlPages()
} else { } else {
c.Data["PageHtml"] = "" c.Data["PageHtml"] = ""

View File

@ -244,7 +244,7 @@ as t group by book_id) as team
LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0 LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0
LEFT JOIN md_members AS member ON rel1.member_id = member.member_id LEFT JOIN md_members AS member ON rel1.member_id = member.member_id
WHERE book.item_id = ? AND (book.privately_owned = 0 or rel.role_id >= 0 or team.role_id >= 0) WHERE book.item_id = ? AND (book.privately_owned = 0 or rel.role_id >= 0 or team.role_id >= 0)
ORDER BY order_index DESC ,book.book_id DESC LIMIT ?,?` ORDER BY order_index ,book.book_id DESC LIMIT ?,?`
_, err = o.Raw(sql2, memberId, memberId, item.ItemId, offset, pageSize).QueryRows(&books) _, err = o.Raw(sql2, memberId, memberId, item.ItemId, offset, pageSize).QueryRows(&books)
@ -262,7 +262,7 @@ as t group by book_id) as team
sql := `SELECT book.*,rel.*,member.account AS create_name FROM md_books AS book sql := `SELECT book.*,rel.*,member.account AS create_name FROM md_books AS book
LEFT JOIN md_relationship AS rel ON rel.book_id = book.book_id AND rel.role_id = 0 LEFT JOIN md_relationship AS rel ON rel.book_id = book.book_id AND rel.role_id = 0
LEFT JOIN md_members AS member ON rel.member_id = member.member_id LEFT JOIN md_members AS member ON rel.member_id = member.member_id
WHERE book.item_id = ? AND book.privately_owned = 0 ORDER BY order_index DESC ,book.book_id DESC LIMIT ?,?` WHERE book.item_id = ? AND book.privately_owned = 0 ORDER BY order_index ,book.book_id DESC LIMIT ?,?`
_, err = o.Raw(sql, item.ItemId, offset, pageSize).QueryRows(&books) _, err = o.Raw(sql, item.ItemId, offset, pageSize).QueryRows(&books)

View File

@ -21,20 +21,7 @@
{{template "widgets/header.tpl" .}} {{template "widgets/header.tpl" .}}
<div class="container manual-body"> <div class="container manual-body">
<div class="row"> <div class="row">
{{if gt (.Labels|len) 1000000}} <div class="manual-list">
<div class="hide tag-container-outer">
<span class="title">热门标签:</span>
<span class="tags">
{{range $index,$item := .Labels}}
<a href="{{urlfor "LabelController.Index" ":key" $item.LabelName}}">{{$item.LabelName}}<span class="detail">{{$item.BookNumber}}</span></a>
{{end}}
</span>
</div>
{{end}}
<div class="manual-list">
{{range $index,$item := .Lists}} {{range $index,$item := .Lists}}
<div class="list-item"> <div class="list-item">
<dl class="manual-item-standard"> <dl class="manual-item-standard">