@Override public <T> Page<T> searchPage(String sql, Class<T> clazz, List<Object> params, Page<T> page) throws Exception { if (StringUtils.isBlank(sql)) { List<T> list = new ArrayList<>(); page.setTotalCount(0); page.setResult(list); return page; } if (params == null) { params = new ArrayList<>(); } StringBuilder sb = new StringBuilder(sql); int count = getCount(sb.toString(), params); page.setTotalCount(count); if (!StringUtils.isBlank(page.getOrder())) { sb.append(" ORDER BY ").append(page.getOrder()); if (!StringUtils.isBlank(page.getSort())) { sb.append(" ").append(page.getSort()); } } sb.append(" LIMIT "); sb.append(String.valueOf(page.getFirstResult())); sb.append(","); sb.append(String.valueOf(page.getPageSize())); List<T> list = searchForList(sb.toString(), clazz, params); page.setResult(list); return page; }
@Override public <T> Page<T> searchPage(SqlHelper sqlHelper, Class<T> clazz, Page<T> page) throws Exception { if (sqlHelper == null || StringUtils.isBlank(sqlHelper.getSql())) { List<T> list = new ArrayList<>(); page.setTotalCount(0); page.setResult(list); return page; } return searchPage(sqlHelper.getSql(), clazz, sqlHelper.getParameters(), page); }