增加分页参数默认值,防止传空时查询全表
This commit is contained in:
parent
947120d136
commit
99e7820bc7
|
|
@ -52,11 +52,21 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String PAGE_NUM = "pageNum";
|
public static final String PAGE_NUM = "pageNum";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前记录起始索引默认值
|
||||||
|
*/
|
||||||
|
public static final int PAGE_NUM_DEFAULT_VALUE = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每页显示记录数
|
* 每页显示记录数
|
||||||
*/
|
*/
|
||||||
public static final String PAGE_SIZE = "pageSize";
|
public static final String PAGE_SIZE = "pageSize";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示记录数默认值
|
||||||
|
*/
|
||||||
|
public static final int PAGE_SIZE_DEFAULT_VALUE = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序列
|
* 排序列
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,8 @@ public class BaseController
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
{
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ public class TableSupport
|
||||||
public static PageDomain getPageDomain()
|
public static PageDomain getPageDomain()
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = new PageDomain();
|
PageDomain pageDomain = new PageDomain();
|
||||||
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM));
|
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM, Constants.PAGE_NUM_DEFAULT_VALUE));
|
||||||
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE));
|
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE, Constants.PAGE_SIZE_DEFAULT_VALUE));
|
||||||
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN));
|
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN));
|
||||||
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC));
|
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC));
|
||||||
return pageDomain;
|
return pageDomain;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue