Search in sources :

Example 1 with PageConfig

use of com.optimus.common.mybatis.annotation.PageConfig in project luntan by caoawei.

the class PageInterceptor method resolvePageParam.

private void resolvePageParam(Object handler, HttpServletRequest request) {
    String $start = request.getParameter(Constant.PAGE_CONFIG_PARAM_START);
    String $limit = request.getParameter(Constant.PAGE_CONFIG_PARAM_LIMIT);
    int start;
    int limit;
    if (Utils.isEmpty($start) || Utils.isEmpty($limit)) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        PageConfig pc = handlerMethod.getMethod().getAnnotation(PageConfig.class);
        start = pc.start();
        limit = pc.limit();
    } else {
        start = Math.max(Integer.valueOf($start), 0);
        limit = Math.min(Integer.valueOf($limit), Integer.MAX_VALUE);
    }
    PageParam pageParam = PageParam.initWithOffset(start, limit);
    ThreadPageUtil.putPageParam(pageParam);
}
Also used : PageConfig(com.optimus.common.mybatis.annotation.PageConfig) PageParam(com.optimus.common.mybatis.PageParam) HandlerMethod(org.springframework.web.method.HandlerMethod)

Aggregations

PageParam (com.optimus.common.mybatis.PageParam)1 PageConfig (com.optimus.common.mybatis.annotation.PageConfig)1 HandlerMethod (org.springframework.web.method.HandlerMethod)1