コード例 #1
0
  public List<User> listByTeam(long teamId) {
    UserExample example = new UserExample();
    example.createCriteria().andTeamIdEqualTo(teamId);
    example.setOrderByClause("create_time DESC");

    return this.userDao.selectByExample(example);
  }
コード例 #2
0
  public List<User> listByTeam(long teamId, int pageNum, Paginator paginator) {
    UserExample example = new UserExample();
    example.createCriteria().andTeamIdEqualTo(teamId);
    example.setOrderByClause("create_time DESC");

    int count = this.userDao.countByExample(example);

    paginator.setItemsPerPage(Constants.PAGE_SIZE);
    paginator.setItems(count);
    paginator.setPage(pageNum);

    int offset = paginator.getBeginIndex() - 1;
    int limit = Constants.PAGE_SIZE;

    RowBounds rowBounds = new RowBounds(offset, limit);

    List<User> list = this.userDao.selectByExampleWithRowbounds(example, rowBounds);

    return list;
  }