Skip to content

Commit

Permalink
fix: 优化分页总记录数数据类型
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Jul 5, 2023
1 parent b632c18 commit 76f04dd
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class PageDataVO<V> implements Serializable {
* 总记录数
*/
@Schema(description = "总记录数")
private Long total;
private int total;

/**
* 基于 MyBatis Plus 分页数据构建分页信息,并将源数据转换为指定类型数据
Expand All @@ -76,7 +76,7 @@ public static <T, V> PageDataVO<V> build(IPage<T> page, Class<V> targetClass) {
}
PageDataVO<V> pageDataVO = new PageDataVO<>();
pageDataVO.setList(BeanUtil.copyToList(page.getRecords(), targetClass));
pageDataVO.setTotal(page.getTotal());
pageDataVO.setTotal((int) page.getTotal());
return pageDataVO;
}

Expand All @@ -95,7 +95,7 @@ public static <V> PageDataVO<V> build(IPage<V> page) {
}
PageDataVO<V> pageDataVO = new PageDataVO<>();
pageDataVO.setList(page.getRecords());
pageDataVO.setTotal(page.getTotal());
pageDataVO.setTotal((int) page.getTotal());
return pageDataVO;
}

Expand All @@ -118,7 +118,7 @@ public static <V> PageDataVO<V> build(int page, int size, List<V> list) {
return pageDataVO;
}

pageDataVO.setTotal((long)list.size());
pageDataVO.setTotal(list.size());
// 对列表数据进行分页
int fromIndex = (page - 1) * size;
int toIndex = page * size + size;
Expand Down

0 comments on commit 76f04dd

Please sign in to comment.