Commit 5bff0cbc authored by ibuler's avatar ibuler

[Update] 修改小bug

parent 1a883bef
......@@ -21,7 +21,7 @@ type Pagination struct {
}
func (p *Pagination) GetNextPageData() []interface{} {
if !p.HasNextPage() {
if !p.HasNext() {
return []interface{}{}
}
p.lock.Lock()
......@@ -30,8 +30,8 @@ func (p *Pagination) GetNextPageData() []interface{} {
return p.GetPageData(p.currentPage)
}
func (p *Pagination) GetPrePageData() []interface{} {
if !p.HasPrePage() {
func (p *Pagination) GetPrevPageData() []interface{} {
if !p.HasPrev() {
return []interface{}{}
}
p.lock.Lock()
......@@ -94,19 +94,19 @@ func (p *Pagination) SetPageSize(size int) {
}
func (p *Pagination) GetPageSize() int {
func (p *Pagination) PageSize() int {
p.lock.RLock()
defer p.lock.RUnlock()
return p.pageSize
}
func (p *Pagination) HasNextPage() bool {
func (p *Pagination) HasNext() bool {
p.lock.RLock()
defer p.lock.RUnlock()
return p.currentPage < p.totalPage
}
func (p *Pagination) HasPrePage() bool {
func (p *Pagination) HasPrev() bool {
p.lock.RLock()
defer p.lock.RUnlock()
return p.currentPage > 1
......
package handler
import (
"cocogo/pkg/common"
"cocogo/pkg/i18n"
"fmt"
"strconv"
"strings"
"cocogo/pkg/common"
"cocogo/pkg/config"
"cocogo/pkg/i18n"
"cocogo/pkg/model"
"cocogo/pkg/utils"
)
......@@ -68,7 +68,7 @@ func (p *AssetPagination) Start() []model.Asset {
defer p.term.SetPrompt("Opt> ")
for {
// 总数据小于page size,则显示所有资产且退出
if p.page.GetPageSize() >= p.page.TotalCount() {
if p.page.PageSize() >= p.page.TotalCount() {
p.currentData = p.assets
p.displayPageAssets()
return []model.Asset{}
......@@ -88,10 +88,10 @@ func (p *AssetPagination) Start() []model.Asset {
case 0, 1:
switch strings.ToLower(line) {
case "p":
if !p.page.HasPrePage() {
if !p.page.HasPrev() {
continue
}
prePageData := p.page.GetPrePageData()
prePageData := p.page.GetPrevPageData()
if len(p.currentData) != len(prePageData) {
p.currentData = make([]model.Asset, len(prePageData))
}
......@@ -100,7 +100,7 @@ func (p *AssetPagination) Start() []model.Asset {
}
case "", "n":
if !p.page.HasNextPage() {
if !p.page.HasNext() {
continue
}
nextPageData := p.page.GetNextPageData()
......@@ -150,7 +150,7 @@ func (p *AssetPagination) displayPageAssets() {
}
w, _ := p.term.GetSize()
caption := fmt.Sprintf(i18n.T("Page: %d, Count: %d, Total Page: %d, Total Count: %d"),
p.page.CurrentPage(), p.page.GetPageSize(), p.page.TotalPage(), p.page.TotalCount(),
p.page.CurrentPage(), p.page.PageSize(), p.page.TotalPage(), p.page.TotalCount(),
)
caption = utils.WrapperString(caption, utils.Green)
table := common.WrapperTable{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment