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