Java Code Examples for com.github.pagehelper.Page#getPageSize()

The following examples show how to use com.github.pagehelper.Page#getPageSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HsqldbDialect.java    From Mybatis-PageHelper with MIT License 6 votes vote down vote up
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
    paramMap.put(PAGEPARAMETER_FIRST, page.getPageSize());
    paramMap.put(PAGEPARAMETER_SECOND, page.getStartRow());
    //处理pageKey
    pageKey.update(page.getPageSize());
    pageKey.update(page.getStartRow());
    //处理参数配置
    if (boundSql.getParameterMappings() != null) {
        List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>(boundSql.getParameterMappings());
        if (page.getPageSize() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
        }
        if (page.getStartRow() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
        }
        MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
        metaObject.setValue("parameterMappings", newParameterMappings);
    }
    return paramMap;
}
 
Example 2
Source File: InformixDialect.java    From Mybatis-PageHelper with MIT License 6 votes vote down vote up
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
    paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
    paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
    //处理pageKey
    pageKey.update(page.getStartRow());
    pageKey.update(page.getPageSize());
    //处理参数配置
    if (boundSql.getParameterMappings() != null) {
        List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>();
        if (page.getStartRow() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
        }
        if (page.getPageSize() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
        }
        newParameterMappings.addAll(boundSql.getParameterMappings());
        MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
        metaObject.setValue("parameterMappings", newParameterMappings);
    }
    return paramMap;
}
 
Example 3
Source File: AbstractHelperDialect.java    From Mybatis-PageHelper with MIT License 6 votes vote down vote up
@Override
public Object afterPage(List pageList, Object parameterObject, RowBounds rowBounds) {
    Page page = getLocalPage();
    if (page == null) {
        return pageList;
    }
    page.addAll(pageList);
    if (!page.isCount()) {
        page.setTotal(-1);
    } else if ((page.getPageSizeZero() != null && page.getPageSizeZero()) && page.getPageSize() == 0) {
        page.setTotal(pageList.size());
    } else if(page.isOrderByOnly()){
        page.setTotal(pageList.size());
    }
    return page;
}
 
Example 4
Source File: LogService.java    From frostmourne with MIT License 5 votes vote down vote up
public PagerContract<AlertLog> findAlertLog(int pageIndex, int pageSize, Date startTime, Date endTime,
                                            Long executeId, Long alarmId, String recipient, String way,
                                            String sendStatus, String inSilence, String alertType) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<AlertLog> list = alertLogMapper.find(startTime, endTime, executeId, alarmId, recipient, way, sendStatus, inSilence, alertType);
    return new PagerContract<>(list, page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 5
Source File: PagedModel.java    From jvue-admin with MIT License 5 votes vote down vote up
/**
 * @param list
 * @return
 * @since  1.0
 */
public static <T> PagedModel<T> from(Page<T> list) {
    PagedModel<T> pageList = new PagedModel<>();
    pageList.pageNum = list.getPageNum();
    pageList.pageSize = list.getPageSize();
    pageList.setTotal(list.getTotal());
    pageList.setData(list.getResult());
    return pageList;
}
 
Example 6
Source File: PageUtis.java    From spring-boot-starter-dao with Apache License 2.0 5 votes vote down vote up
public static <T, TO> PageInfo<TO> outPage(Page<T> page, List<TO> tos) {
	if (page == null)
		return new PageInfo<TO>();
	int pageSize = page.getPageSize();
	int pageNo = page.getPageNum();
	long total = page.getTotal();
	return new PageInfo<TO>(pageNo, pageSize, total, tos);
}
 
Example 7
Source File: HsqldbDialect.java    From Mybatis-PageHelper with MIT License 5 votes vote down vote up
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
    StringBuilder sqlBuilder = new StringBuilder(sql.length() + 20);
    sqlBuilder.append(sql);
    if (page.getPageSize() > 0) {
        sqlBuilder.append(" LIMIT ? ");
    }
    if (page.getStartRow() > 0) {
        sqlBuilder.append(" OFFSET ? ");
    }
    return sqlBuilder.toString();
}
 
Example 8
Source File: InformixDialect.java    From Mybatis-PageHelper with MIT License 5 votes vote down vote up
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
    StringBuilder sqlBuilder = new StringBuilder(sql.length() + 40);
    sqlBuilder.append("SELECT ");
    if (page.getStartRow() > 0) {
        sqlBuilder.append(" SKIP ? ");
    }
    if (page.getPageSize() > 0) {
        sqlBuilder.append(" FIRST ? ");
    }
    sqlBuilder.append(" * FROM ( ");
    sqlBuilder.append(sql);
    sqlBuilder.append(" ) TEMP_T ");
    return sqlBuilder.toString();
}
 
Example 9
Source File: AbstractHelperDialect.java    From Mybatis-PageHelper with MIT License 5 votes vote down vote up
@Override
public boolean afterCount(long count, Object parameterObject, RowBounds rowBounds) {
    Page page = getLocalPage();
    page.setTotal(count);
    if (rowBounds instanceof PageRowBounds) {
        ((PageRowBounds) rowBounds).setTotal(count);
    }
    //pageSize < 0 的时候,不执行分页查询
    //pageSize = 0 的时候,还需要执行后续查询,但是不会分页
    if (page.getPageSize() < 0) {
        return false;
    }
    return count > ((page.getPageNum() - 1) * page.getPageSize());
}
 
Example 10
Source File: AbstractHelperDialect.java    From Mybatis-PageHelper with MIT License 5 votes vote down vote up
@Override
public boolean beforePage(MappedStatement ms, Object parameterObject, RowBounds rowBounds) {
    Page page = getLocalPage();
    if (page.isOrderByOnly() || page.getPageSize() > 0) {
        return true;
    }
    return false;
}
 
Example 11
Source File: AlarmAdminService.java    From frostmourne with MIT License 4 votes vote down vote up
public PagerContract<Alarm> find(int pageIndex, int pageSize, Long alarmId, String name,
                                 String teamName, String status) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<Alarm> list = this.alarmMapper.find(alarmId, name, teamName, status);
    return new PagerContract<>(list, page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 12
Source File: LogService.java    From frostmourne with MIT License 4 votes vote down vote up
public PagerContract<AlarmLog> findAlarmLog(int pageIndex, int pageSize, Date startTime,
                                    Date endTime, Long alarmId, String verifyResult, String executeResult) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<AlarmLog> list = alarmLogMapper.find(startTime, endTime, alarmId, verifyResult, executeResult);
    return new PagerContract<>(list, page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 13
Source File: DataAdminService.java    From frostmourne with MIT License 4 votes vote down vote up
public PagerContract<DataSourceContract> findDatasource(int pageIndex, int pageSize, String datasourceType) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<DataSource> list = this.dataSourceMapper.find(datasourceType);
    return new PagerContract<>(list.stream().map(DataSourceTransformer::model2Contract).collect(Collectors.toList()),
            page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 14
Source File: DataAdminService.java    From frostmourne with MIT License 4 votes vote down vote up
public PagerContract<DataNameContract> findDataName(int pageIndex, int pageSize, String datasourceType, Long datasourceId) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<DataName> list = this.dataNameMapper.find(datasourceType, datasourceId);
    return new PagerContract<>(list.stream().map(DataAdminService::toDataNameContract).collect(Collectors.toList()),
            page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 15
Source File: PageResultWrapper.java    From magic-starter with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * 构造分页对象
 *
 * @param pageData 当前页数据
 * @param <T>泛型
 * @return 分页对象
 */
public static <T> PageResult<T> wrapper(Page<T> pageData) {
	return new PageResult<>(pageData.getPageNum(), pageData.getPageSize(), pageData.getPages(), pageData.getTotal(), pageData.getResult());
}