forked from macrozheng/mall
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfa9871
commit eca02f2
Showing
4 changed files
with
103 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
mall-demo/src/main/java/com/macro/mall/demo/dto/CommonPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.macro.mall.demo.dto; | ||
|
||
import com.github.pagehelper.PageInfo; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* 分页数据封装类 | ||
*/ | ||
public class CommonPage<T> { | ||
private Integer pageNum; | ||
private Integer pageSize; | ||
private Long totalPage; | ||
private List<T> list; | ||
|
||
/** | ||
* 将PageHelper分页后的list转为分页信息 | ||
*/ | ||
public static <T> CommonPage<T> restPage(List<T> list) { | ||
CommonPage<T> result = new CommonPage<>(); | ||
PageInfo<T> pageInfo = new PageInfo<>(list); | ||
result.setTotalPage(pageInfo.getTotal() / pageInfo.getPageSize()); | ||
result.setPageNum(pageInfo.getPageNum()); | ||
result.setPageSize(pageInfo.getPageSize()); | ||
result.setList(pageInfo.getList()); | ||
return result; | ||
} | ||
|
||
public Integer getPageNum() { | ||
return pageNum; | ||
} | ||
|
||
public void setPageNum(Integer pageNum) { | ||
this.pageNum = pageNum; | ||
} | ||
|
||
public Integer getPageSize() { | ||
return pageSize; | ||
} | ||
|
||
public void setPageSize(Integer pageSize) { | ||
this.pageSize = pageSize; | ||
} | ||
|
||
public Long getTotalPage() { | ||
return totalPage; | ||
} | ||
|
||
public void setTotalPage(Long totalPage) { | ||
this.totalPage = totalPage; | ||
} | ||
|
||
public List<T> getList() { | ||
return list; | ||
} | ||
|
||
public void setList(List<T> list) { | ||
this.list = list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters