com.github.pagehelper.PageHelper.offsetPage()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(342)

本文整理了Java中com.github.pagehelper.PageHelper.offsetPage()方法的一些代码示例,展示了PageHelper.offsetPage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PageHelper.offsetPage()方法的具体详情如下:
包路径:com.github.pagehelper.PageHelper
类名称:PageHelper
方法名:offsetPage

PageHelper.offsetPage介绍

暂无

代码示例

代码示例来源:origin: shuzheng/zheng

@Override
public List<Record> selectByExampleWithBLOBsForOffsetPage(Example example, Integer offset, Integer limit) {
  try {
    DynamicDataSource.setDataSource(DataSourceEnum.SLAVE.getName());
    Method selectByExampleWithBLOBs = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
    PageHelper.offsetPage(offset, limit, false);
    Object result = selectByExampleWithBLOBs.invoke(mapper, example);
    return (List<Record>) result;
  } catch (IllegalAccessException e) {
    e.printStackTrace();
  } catch (InvocationTargetException e) {
    e.printStackTrace();
  } catch (NoSuchMethodException e) {
    e.printStackTrace();
  }
  DynamicDataSource.clearDataSource();
  return null;
}

代码示例来源:origin: shuzheng/zheng

@Override
public List<Record> selectByExampleForOffsetPage(Example example, Integer offset, Integer limit) {
  try {
    DynamicDataSource.setDataSource(DataSourceEnum.SLAVE.getName());
    Method selectByExample = mapper.getClass().getDeclaredMethod("selectByExample", example.getClass());
    PageHelper.offsetPage(offset, limit, false);
    Object result = selectByExample.invoke(mapper, example);
    return (List<Record>) result;
  } catch (IllegalAccessException e) {
    e.printStackTrace();
  } catch (InvocationTargetException e) {
    e.printStackTrace();
  } catch (NoSuchMethodException e) {
    e.printStackTrace();
  }
  DynamicDataSource.clearDataSource();
  return null;
}

代码示例来源:origin: javahongxi/whatsmars

@Override
public Page<User> query(int offset, int limit) {
  return PageHelper.offsetPage(offset, limit).doSelectPage(() -> userMapper.query());
}

代码示例来源:origin: liunian1004/vua

@Override
public List<Record> selectByExampleWithBLOBsForOffsetPage(Example example, Integer offset, Integer limit) {
  try {
    Method selectByExampleWithBLOBs = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
    PageHelper.offsetPage(offset, limit);
    Object result = selectByExampleWithBLOBs.invoke(mapper, example);
    return (List<Record>)result;
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: liunian1004/vua

@Override
public List<Record> selectByExampleForOffsetPage(Example example, Integer offset, Integer limit) {
  try {
    Method selectByExample = mapper.getClass().getDeclaredMethod("selectByExample", example.getClass());
    PageHelper.offsetPage(offset, limit, false);
    Object result = selectByExample.invoke(mapper, example);
    return (List<Record>) result;
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: techa03/goodsKill

@Override
public List<Entity> selectByExampleForOffsetPage(Example example, Integer offset, Integer limit) {
  try {
    mapper = (Mapper) getMapper();
    Method selectByExample = mapper.getClass().getDeclaredMethod("selectByExample", example.getClass());
    PageHelper.offsetPage(offset, limit, false);
    Object result = selectByExample.invoke(mapper, example);
    return (List<Entity>) result;
  } catch (IllegalAccessException e) {
    log.error(e.getMessage(), e);
  } catch (InvocationTargetException e) {
    log.error(e.getMessage(), e);
  } catch (NoSuchMethodException e) {
    log.error(e.getMessage(), e);
  }
  return null;
}

代码示例来源:origin: techa03/goodsKill

@Override
public List<Entity> selectByExampleWithBLOBsForOffsetPage(Example example, Integer offset, Integer limit) {
  try {
    mapper = (Mapper) getMapper();
    Method selectByExampleWithBLOBs = mapper.getClass().getDeclaredMethod("selectByExampleWithBLOBs", example.getClass());
    PageHelper.offsetPage(offset, limit, false);
    Object result = selectByExampleWithBLOBs.invoke(mapper, example);
    return (List<Entity>) result;
  } catch (IllegalAccessException e) {
    log.error(e.getMessage(), e);
  } catch (InvocationTargetException e) {
    log.error(e.getMessage(), e);
  } catch (NoSuchMethodException e) {
    log.error(e.getMessage(), e);
  }
  return null;
}

代码示例来源:origin: sail-y/spring-boot-admin

@Override
public DataTable<User> tables(UserVO userVO) {
  PageHelper.offsetPage(userVO.getStart(), userVO.getLength());
  List<User> users = userMapper.findUser(new HashMap<>());
  DataTable<User> tables = new DataTable<>();
  tables.setRecordsTotal(((Page) users).getTotal());
  tables.setRecordsFiltered(tables.getRecordsTotal());
  tables.setDraw(userVO.getDraw());
  tables.setData(users);
  return tables;
}

代码示例来源:origin: sail-y/spring-boot-admin

@Override
public DataTable<Role> tables(RoleVO roleVO) {
  PageHelper.offsetPage(roleVO.getStart(), roleVO.getLength());
  List<Role> roles = roleMapper.getRoleList(new HashMap<>());
  DataTable<Role> tables = new DataTable<>();
  tables.setRecordsTotal(((Page) roles).getTotal());
  tables.setRecordsFiltered(tables.getRecordsTotal());
  tables.setDraw(roleVO.getDraw());
  tables.setData(roles);
  return tables;
}

代码示例来源:origin: cjbi/wetech-admin

@Override
public PageResultSet<RoleDto> findByPage(RoleQuery roleQuery) {
  PageHelper.offsetPage(roleQuery.getOffset(), roleQuery.getLimit());
  if(!StringUtils.isEmpty(roleQuery.getOrderBy())) {
    PageHelper.orderBy(roleQuery.getOrderBy());
  }
  Weekend<Role> example = Weekend.of(Role.class);
  WeekendCriteria<Role, Object> criteria = example.weekendCriteria();
  if(!StringUtils.isEmpty(roleQuery.getRole())) {
    criteria.andLike(Role::getRole,"%" + roleQuery.getRole() + "%");
  }
  if(!StringUtils.isEmpty(roleQuery.getDescription())) {
    criteria.andLike(Role::getDescription,"%" + roleQuery.getDescription() + "%");
  }
  PageResultSet<RoleDto> resultSet = new PageResultSet<>();
  List<RoleDto> dtoList = new ArrayList<>();
  roleMapper.selectByExample(example).forEach(r -> {
    RoleDto dto = new RoleDto(r);
    dto.setResourceNames(getResourceNames(r.getResourceIdList()));
    dtoList.add(dto);
  });
  long total = roleMapper.selectCountByExample(example);
  resultSet.setRows(dtoList);
  resultSet.setTotal(total);
  return resultSet;
}

代码示例来源:origin: cjbi/wetech-admin

@Override
public PageResultSet<Group> findByPage(GroupQuery groupQuery) {
  if (!StringUtils.isEmpty(groupQuery.getOrderBy())) {
    PageHelper.orderBy(groupQuery.getOrderBy());
  }
  Weekend<Group> weekend = Weekend.of(Group.class);
  WeekendCriteria<Group, Object> criteria = weekend.weekendCriteria();
  if (!StringUtils.isEmpty(groupQuery.getName())) {
    criteria.andLike(Group::getName, groupQuery.getName());
  }
  PageResultSet<Group> resultSet = new PageResultSet<>();
  Page page = PageHelper.offsetPage(groupQuery.getOffset(), groupQuery.getLimit()).doSelectPage(() -> groupMapper.selectByExample(weekend));
  resultSet.setRows(page);
  resultSet.setTotal(page.getTotal());
  return resultSet;
}

代码示例来源:origin: cjbi/wetech-admin

@Override
public PageResultSet<UserDto> findByPage(UserQuery userQuery) {
  if(!StringUtils.isEmpty(userQuery.getOrderBy())) {
    PageHelper.orderBy(userQuery.getOrderBy());
  }
  Weekend<User> example = Weekend.of(User.class);
  WeekendCriteria<User, Object> criteria = example.weekendCriteria();
  if (!StringUtils.isEmpty(userQuery.getUsername())) {
    criteria.andLike(User::getUsername, "%" + userQuery.getUsername() + "%");
  }
  if(userQuery.getLocked() != null) {
    criteria.andEqualTo(User::getLocked,userQuery.getLocked());
  }
  List<UserDto> dtoList = new ArrayList<>();
  PageHelper.offsetPage(userQuery.getOffset(), userQuery.getLimit());
  userMapper.selectByExample(example).forEach(u -> {
    UserDto dto = new UserDto(u);
    dto.setOrganizationName(getOrganizationName(Long.valueOf(dto.getOrganizationId())));
    dto.setRoleNames(getRoleNames(dto.getRoleIdList()));
    dto.setGroupNames(getGroupNames(dto.getGroupIdList()));
    dtoList.add(dto);
  });
  long total = userMapper.selectCountByExample(example);
  PageResultSet<UserDto> resultSet = new PageResultSet<>();
  resultSet.setRows(dtoList);
  resultSet.setTotal(total);
  return resultSet;
}

代码示例来源:origin: cjbi/wetech-admin

Page page = PageHelper.offsetPage(log.getOffset(), log.getLimit()).doSelectPage(()-> logMapper.selectByExample(example));

相关文章