@@ -82,6 +82,7 @@ type ObjLabelResp struct {
8282const (
8383 DefaultPerPage = 200
8484 MaxPerPage = 500
85+ AllPerPage = - 1
8586)
8687
8788func FsList (c * gin.Context ) {
@@ -136,7 +137,7 @@ func FsList(c *gin.Context) {
136137 total , pageObjs := pagination (filtered , & req .PageReq )
137138 respContent := toObjsResp (pageObjs , reqPath , isEncrypt (meta , reqPath ))
138139 pagesTotal := calcPagesTotal (total , req .PerPage )
139- hasMore := req .Page * req .PerPage < total
140+ hasMore := req .PerPage != AllPerPage && req . Page * req .PerPage < total
140141
141142 common .SuccessResp (c , FsListResp {
142143 Content : respContent ,
@@ -253,7 +254,10 @@ func normalizeListPage(page, perPage int) (int, int) {
253254 effPage = 1
254255 }
255256 effPerPage := perPage
256- if effPerPage <= 0 {
257+ if effPerPage < 0 {
258+ return effPage , AllPerPage
259+ }
260+ if effPerPage == 0 {
257261 effPerPage = DefaultPerPage
258262 }
259263 if effPerPage > MaxPerPage {
@@ -263,6 +267,12 @@ func normalizeListPage(page, perPage int) (int, int) {
263267}
264268
265269func calcPagesTotal (total , perPage int ) int {
270+ if perPage == AllPerPage {
271+ if total > 0 {
272+ return 1
273+ }
274+ return 0
275+ }
266276 if total <= 0 || perPage <= 0 {
267277 return 0
268278 }
@@ -272,6 +282,9 @@ func calcPagesTotal(total, perPage int) int {
272282func pagination (objs []model.Obj , req * model.PageReq ) (int , []model.Obj ) {
273283 pageIndex , pageSize := req .Page , req .PerPage
274284 total := len (objs )
285+ if pageSize == AllPerPage {
286+ return total , objs
287+ }
275288 start := (pageIndex - 1 ) * pageSize
276289 if start > total {
277290 return total , []model.Obj {}
0 commit comments