Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
koko
Commits
5bff0cbc
Commit
5bff0cbc
authored
May 16, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改小bug
parent
1a883bef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
pagination.go
pkg/common/pagination.go
+6
-6
pagination.go
pkg/handler/pagination.go
+7
-7
No files found.
pkg/common/pag
n
ination.go
→
pkg/common/pagination.go
View file @
5bff0cbc
...
...
@@ -21,7 +21,7 @@ type Pagination struct {
}
func
(
p
*
Pagination
)
GetNextPageData
()
[]
interface
{}
{
if
!
p
.
HasNext
Page
()
{
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
.
HasPre
Page
()
{
func
(
p
*
Pagination
)
GetPre
v
PageData
()
[]
interface
{}
{
if
!
p
.
HasPre
v
()
{
return
[]
interface
{}{}
}
p
.
lock
.
Lock
()
...
...
@@ -94,19 +94,19 @@ func (p *Pagination) SetPageSize(size int) {
}
func
(
p
*
Pagination
)
Get
PageSize
()
int
{
func
(
p
*
Pagination
)
PageSize
()
int
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
return
p
.
pageSize
}
func
(
p
*
Pagination
)
HasNext
Page
()
bool
{
func
(
p
*
Pagination
)
HasNext
()
bool
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
return
p
.
currentPage
<
p
.
totalPage
}
func
(
p
*
Pagination
)
HasPre
Page
()
bool
{
func
(
p
*
Pagination
)
HasPre
v
()
bool
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
return
p
.
currentPage
>
1
...
...
pkg/handler/pagination.go
View file @
5bff0cbc
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
.
Get
PageSize
()
>=
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
.
HasPre
Page
()
{
if
!
p
.
page
.
HasPre
v
()
{
continue
}
prePageData
:=
p
.
page
.
GetPrePageData
()
prePageData
:=
p
.
page
.
GetPre
v
PageData
()
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
.
HasNext
Page
()
{
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
.
Get
PageSize
(),
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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment