use of com.github.pagehelper.model.CountryQueryModel in project Mybatis-PageHelper by pagehelper.
the class ArgumentsObjTest method testArgumentsObj.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testArgumentsObj() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
CountryQueryModel queryModel = new CountryQueryModel();
queryModel.setPageNum(1);
queryModel.setPageSize(10);
queryModel.setOrderBy("id desc");
List<Country> list = countryMapper.selectByQueryModel(queryModel);
assertEquals(10, list.size());
assertEquals(183, ((Page<?>) list).getTotal());
queryModel.setPageNum(2);
queryModel.setOrderBy(null);
list = countryMapper.selectByQueryModel(queryModel);
assertEquals(10, list.size());
assertEquals(183, ((Page<?>) list).getTotal());
queryModel.setPageNum(3);
queryModel.setPageSize(20);
list = countryMapper.selectByQueryModel(queryModel);
assertEquals(20, list.size());
assertEquals(183, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
Aggregations