Commit da56fc60 by java-李谡

修改分页

parent 0ce6d7b0
...@@ -105,7 +105,6 @@ public class StatisticalController { ...@@ -105,7 +105,6 @@ public class StatisticalController {
StatisticalListBean bean = requestBean.getObjectBean(StatisticalListBean.class); StatisticalListBean bean = requestBean.getObjectBean(StatisticalListBean.class);
String message = statisticalService.validate(bean); String message = statisticalService.validate(bean);
if (message == null) { if (message == null) {
bean.setPageSize(1000);
// 参数校验为通过 // 参数校验为通过
PageEntity<StatisticalListEntity> list = statisticalService.getList(bean); PageEntity<StatisticalListEntity> list = statisticalService.getList(bean);
// 查询结果为空 // 查询结果为空
...@@ -130,7 +129,8 @@ public class StatisticalController { ...@@ -130,7 +129,8 @@ public class StatisticalController {
StatisticalListBean bean = requestBean.getObjectBean(StatisticalListBean.class); StatisticalListBean bean = requestBean.getObjectBean(StatisticalListBean.class);
String message = statisticalService.validate(bean); String message = statisticalService.validate(bean);
if (message == null) { if (message == null) {
bean.setPageSize(1000); bean.setPageNo(1);
bean.setPageSize(9999999);
// 参数校验为通过 // 参数校验为通过
PageEntity<StatisticalListEntity> page = statisticalService.getList(bean); PageEntity<StatisticalListEntity> page = statisticalService.getList(bean);
List<StatisticalListEntity> list = new ArrayList<StatisticalListEntity>(); List<StatisticalListEntity> list = new ArrayList<StatisticalListEntity>();
......
...@@ -14,6 +14,7 @@ import com.ejweb.modules.airport.entity.StatisticalListEntity; ...@@ -14,6 +14,7 @@ import com.ejweb.modules.airport.entity.StatisticalListEntity;
import com.ejweb.modules.verify.bean.AirlineVerifiedAddBean; import com.ejweb.modules.verify.bean.AirlineVerifiedAddBean;
import com.ejweb.modules.verify.dao.AirlineVerifiedDao; import com.ejweb.modules.verify.dao.AirlineVerifiedDao;
import com.ejweb.modules.verify.dao.AirlineVerifyDao; import com.ejweb.modules.verify.dao.AirlineVerifyDao;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -142,27 +143,36 @@ public class StatisticalService extends BaseService<StatisticalDao> { ...@@ -142,27 +143,36 @@ public class StatisticalService extends BaseService<StatisticalDao> {
public PageEntity<StatisticalListEntity> getList(StatisticalListBean statisticalListBean){ public PageEntity<StatisticalListEntity> getList(StatisticalListBean statisticalListBean){
PageEntity<StatisticalListEntity> page = new PageEntity<StatisticalListEntity>();
PageInfo<StatisticalListEntity> pageInfo = null;
List<StatisticalListEntity> lists = null; List<StatisticalListEntity> lists = null;
lists = statisticalDao.getList(statisticalListBean); lists = statisticalDao.getList(statisticalListBean);
if (Objects.nonNull(statisticalListBean.getAirlineStatus())){ if (Objects.nonNull(statisticalListBean.getAirlineStatus())) {
//使用迭代器进行筛选 //使用迭代器进行筛选
Iterator<StatisticalListEntity> iter = lists.iterator(); Iterator<StatisticalListEntity> iter = lists.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
//当此对象状态与传入状态不一致时remove对象 //当此对象状态与传入状态不一致时remove对象
if (iter.next().getAirlineStatus() != statisticalListBean.getAirlineStatus()){ if (iter.next().getAirlineStatus() != statisticalListBean.getAirlineStatus()) {
iter.remove(); iter.remove();
} }
} }
} }
pageInfo = new PageInfo<StatisticalListEntity>(lists); //创建Page类
page.setPageNo(pageInfo.getPageNum()); Page page = new Page(statisticalListBean.getPageNo(), statisticalListBean.getPageSize());
page.setPageSize(pageInfo.getPageSize()); //为Page类中的total属性赋值
page.setCount(pageInfo.getTotal()); int total = lists.size();
page.setTotalPage(pageInfo.getPages()); page.setTotal(total);
page.setList(pageInfo.getList()); //计算当前需要显示的数据下标起始值
return page; int startIndex = (statisticalListBean.getPageNo() - 1) * statisticalListBean.getPageSize();
int endIndex = Math.min(startIndex + statisticalListBean.getPageSize(), total);
//从链表中截取需要显示的子链表,并加入到Page
page.addAll(lists.subList(startIndex, endIndex));
//以Page创建PageInfo
PageEntity<StatisticalListEntity> pageEntity = new PageEntity<>();
pageEntity.setPageNo(page.getPageNum());
pageEntity.setPageSize(page.getPageSize());
pageEntity.setCount(page.getTotal());
pageEntity.setTotalPage(page.getPages());
pageEntity.setList(page.getResult());
return pageEntity;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment