package com.skycloud.mini.common.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.skycloud.mini.service.impl.IbmHmcServiceImpl;
public class PageUtils {
private static final Log log = LogFactory.getLog(IbmHmcServiceImpl.class);
/**
* 获取分页参数
* @param pageSize
* @param pageNumber
* @param totalSize
* @return
* */
public static PageObject getPageObject(PageObject page){
int totalSize = page.getTotalSize();
int pageSize = page.getPageSize();
if(pageSize == 0){
pageSize = 10;
}
int pageNumber = page.getPageNumber();
if(pageNumber <= 0){
log.error("bnussiness error : pageNumber ="+pageNumber);
}
int totalPage = totalSize / pageSize;
if(totalSize % pageSize != 0){
totalPage++;
}
page.setTotalPage(totalPage);
int beginNum = pageSize * (pageNumber-1);
if(beginNum > totalSize){
beginNum = totalSize;
}
page.setBeginNumber(beginNum);
int endNum = beginNum + pageSize -1;
if(endNum > totalSize){
endNum = totalSize;
}
page.setEndNumber(endNum);
return page;
}
}