Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][API] list paging missing totalpage #15619

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;

import lombok.Data;
import lombok.Setter;

import com.baomidou.mybatisplus.core.metadata.IPage;

Expand All @@ -38,6 +39,7 @@ public class PageInfo<T> {
/**
* total Page
*/
@Setter
private Integer totalPage;
/**
* page size
Expand Down Expand Up @@ -75,4 +77,15 @@ public static <T> PageInfo<T> of(IPage<T> iPage) {
public static <T> PageInfo<T> of(Integer currentPage, Integer pageSize) {
return new PageInfo<>(currentPage, pageSize);
}

public Integer getTotalPage() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to achieve the same function, and is simpler
this.totalPage = Math.ceil(this.total / this.pageSize);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaZuiZui
The original code is from a previously deleted section #15181. But your suggestions are better, there is no reason not to optimize, you are welcome to create a PR❤️.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaZuiZui The original code is from a previously deleted section #15181. But your suggestions are better, there is no reason not to optimize, you are welcome to create a PR❤️.

+1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have submitted PR
#15620

if (pageSize == null || pageSize == 0) {
pageSize = 7;
}
this.totalPage =
(this.total % this.pageSize) == 0
? ((this.total / this.pageSize) == 0 ? 1 : (this.total / this.pageSize))
: (this.total / this.pageSize + 1);
return this.totalPage;
}
}
Loading