SmsContentLogDAO extends BaseIbatisDAO { @SuppressWarnings({ "rawtypes", "unchecked" }) public Page pagedQuery(final Map parameterObject, final int currentPage, final int limit) { Assert.isTrue(currentPage >= 0, "pageNo should start from 0"); SmsLogStat sls = (SmsLogStat) queryForObject("SMS_CONTENT_LOG.count", parameterObject); Long totalCount = sls.getTotal(); Assert.notNull(totalCount, "totalCount Error"); if (totalCount.longValue() == 0) { return new Page(0); } List list; long totalPageCount = 0; long startIndex = 0; if (limit > 0) { totalPageCount = totalCount / limit; totalPageCount += ((totalCount % limit) > 0) ? 1 : 0; if (currentPage > totalPageCount) { startIndex = (totalPageCount - 1) * limit; } else { startIndex = (currentPage - 1) * limit; } Map newParameterObject = new HashMap(); if (null != parameterObject) { newParameterObject.putAll(parameterObject); } newParameterObject.put("startIndex", startIndex); newParameterObject.put("limit", limit); list = super.queryForList( "SMS_CONTENT_LOG.query", newParameterObject); } else { list = super.queryForList( "SMS_CONTENT_LOG.query", parameterObject); } Page page = new Page(totalCount, limit, 12); page.setItems(list); return page; }  SmsContentLog save(final SmsContentLog log); void saveBatch(final Map<String, Object> parameters); Object querySmsContentLogByPk(final Long id); @SuppressWarnings({"rawtypes" }) List query(final Map<String, Object> parameters); @SuppressWarnings({ "rawtypes", "unchecked" }) Page pagedQuery(final Map parameterObject, final int currentPage, final int limit); void increaseNumbers(final Serializable id); void updateReport(final Long serialId, final Integer reportStatus, final Date date, final String memo); void updateReport(final String beforeMemo, final Integer reportStatus, final Date date, final String memo); @SuppressWarnings("unchecked") List<SmsLogStat> queryStat(final Map<String, Object> parameters); long queryMMSStat(final Map<String, Object> parameters); void moveSmsContentLogToHis(final Map<String, Object> parameters); long count(final Map<String, Object> parameters); @SuppressWarnings("unchecked") List<SmsContentLog> getListByParams(Map<String, Object> params); Long getListCountByParams(Map<String, Object> params); int updateSmsLog(SmsContentLog smsContentLog); @SuppressWarnings("unchecked") List<SmsContentLog> getSmsLogListByParams(Map<String, Object> paramMap); @SuppressWarnings("unchecked") List<SmsContentLog> getResendSmsLogList();  }
@Test @SuppressWarnings("unchecked") public void testPagedQuery() { Page<SmsContentLog> page = smsContentLogDAO.pagedQuery(new HashMap<String, Object>(), 1, 10); Assert.assertNotNull(page); Assert.assertEquals(10, page.getItems().size()); Assert.assertEquals(1, page.getCurrentPage()); Assert.assertEquals(1, page.getStartRows()); }