Skip to content

Commit

Permalink
Merge pull request #1344 from lowcoder-org/fix/pagination
Browse files Browse the repository at this point in the history
Fixed pagination start value
  • Loading branch information
FalkWolsky authored Nov 27, 2024
2 parents 6bf8b1c + 3cf31b6 commit d12d09d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Flux<OrgMember> getOrganizationMembers(String orgId) {

@Override
public Flux<OrgMember> getOrganizationMembers(String orgId, int page, int count) {
return biRelationService.getBySourceId(ORG_MEMBER, orgId, PageRequest.of(page, count))
return biRelationService.getBySourceId(ORG_MEMBER, orgId, PageRequest.of(page - 1, count))
.map(OrgMember::from);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Mono<GroupMemberAggregateView> getGroupMembers(String groupId, int page,
.filter(Objects::nonNull)
.toList();
var pageTotal = list.size();
list = list.subList(page * count, Math.min(page * count + count, pageTotal));
list = list.subList((page - 1) * count, count == 0 ? pageTotal : Math.min(page * count, pageTotal));
return Pair.of(list, pageTotal);
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public Mono<GroupListResponseView<List<GroupView>>> getOrgGroups(@RequestParam(r
.filter(orgMember -> !orgMember.isAdmin() && !orgMember.isSuperAdmin() &&
devMembers.stream().noneMatch(devMember -> devMember.getUserId().equals(orgMember.getUserId()))).toList().size();

var subList = groupList.subList((pageNum - 1) * pageSize, pageSize <= 0?groupList.size():pageNum * pageSize);
var subList = groupList.subList((pageNum - 1) * pageSize, pageSize <= 0?groupList.size():Math.min(pageNum * pageSize, groupList.size()));
return new GroupListResponseView<>(ResponseView.SUCCESS,
"",
subList,
totalAdmins,
totalAdminsAndDevelopers,
totalDevelopersOnly,
totalOtherMembers,
subList.size(),
groupList.size(),
pageNum,
pageSize);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private Mono<OrgMemberListView> getOrgMemberListView(String orgId, int page, int
.filter(Objects::nonNull)
.collect(Collectors.toList());
var pageTotal = list.size();
list = list.subList(page * count, Math.min(page * count + count, pageTotal));
list = list.subList((page - 1) * count, count == 0 ? pageTotal : Math.min(page * count, pageTotal));
return Pair.of(list, pageTotal);
});
})
Expand Down

0 comments on commit d12d09d

Please sign in to comment.