use of com.github.pagehelper.PageInfo in project TeachingInSimulation by ScOrPiOzzy.
the class ClassServiceImpl method findClasses.
@Override
public PageInfo<Class> findClasses(int pageIndex, int pageSize) {
ClassMapper classMapper = (ClassMapper) mapper;
PageHelper.startPage(pageIndex, pageSize);
List<Class> result = classMapper.findClasses();
PageInfo<Class> page = new PageInfo<>(result);
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", page.getTotal(), pageIndex, pageSize, page.getPages());
return page;
}
use of com.github.pagehelper.PageInfo in project TeachingInSimulation by ScOrPiOzzy.
the class LibraryPublishServiceImpl method findPublishForTeacher.
@Override
public PageInfo<LibraryPublishForTeacher> findPublishForTeacher(int pageIndex, int pageSize, int creator) {
LibraryPublishMapper publishMapper = (LibraryPublishMapper) mapper;
PageHelper.startPage(pageIndex, pageSize);
List<LibraryPublishForTeacher> result = publishMapper.findPublishForTeacher(creator);
PageInfo<LibraryPublishForTeacher> page = new PageInfo<>(result);
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pageIndex, pageSize, page.getPages());
return page;
}
use of com.github.pagehelper.PageInfo in project TeachingInSimulation by ScOrPiOzzy.
the class LibraryServiceImpl method findLibraryByType.
@Override
public PageInfo<Library> findLibraryByType(int pageIndex, int pageSize, int type) {
Condition condition = new Condition(Library.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("type", type);
criteria.andEqualTo("del", 0);
PageHelper.startPage(pageIndex, pageSize);
List<Library> result = findByCondition(condition);
PageInfo<Library> page = new PageInfo<Library>(result);
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pageIndex, pageSize, page.getPages());
return page;
}
use of com.github.pagehelper.PageInfo in project TeachingInSimulation by ScOrPiOzzy.
the class QuestionServiceImpl method findQuestionsByLibrary.
@Override
public PageInfo<Question> findQuestionsByLibrary(int pageIndex, int pageSize, int rid) {
Condition condition = new Condition(Question.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("relateId", rid);
PageHelper.startPage(pageIndex, pageSize);
List<Question> result = findByCondition(condition);
PageInfo<Question> page = new PageInfo<>(result);
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pageIndex, pageSize, page.getPages());
return page;
}
use of com.github.pagehelper.PageInfo in project TeachingInSimulation by ScOrPiOzzy.
the class ResourceServiceImpl method findResourcesByCreator.
@Override
public PageInfo<Resource> findResourcesByCreator(int pagination, int pageSize, List<Integer> resourceTypes, String keyword, String orderByClause, Integer creator) {
// 获取当前登陆者身份信息
Condition condition = new Condition(Resource.class);
// 条件1、查找用户指定的几种资源类型
if (resourceTypes.size() == 0) {
return new PageInfo<Resource>(new ArrayList<Resource>());
} else {
Criteria criteria = condition.createCriteria();
criteria.andIn("type", resourceTypes);
}
// 条件2、关键字搜索
if (keyword != null && !"".equals(keyword)) {
Criteria criteria = condition.createCriteria();
List<String> words = StringUtil.split(keyword, ' ');
for (String word : words) {
criteria.orLike("keyword", "%" + word + "%");
}
condition.and(criteria);
}
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("creator", creator);
condition.and(criteria);
// 开始分页查询
PageHelper.startPage(pagination, pageSize, orderByClause);
List<Resource> result = findByCondition(condition);
PageInfo<Resource> page = new PageInfo<Resource>(result);
// 查到的总记录数
// 解释一下:这个page.getTotal(),是所有符合条件的记录数。
// result.size():是当前页中的数据量 <= pageSize
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pagination, pageSize, page.getPages());
return page;
}
Aggregations