public boolean hasTeamUser(long teamId) {
    UserExample example = new UserExample();
    example.createCriteria().andTeamIdEqualTo(teamId);

    List<User> users = this.userDao.selectByExample(example);
    return (users != null) && !users.isEmpty();
  }
  public List<User> listByTeam(long teamId) {
    UserExample example = new UserExample();
    example.createCriteria().andTeamIdEqualTo(teamId);
    example.setOrderByClause("create_time DESC");

    return this.userDao.selectByExample(example);
  }
 public User get(String username) {
   UserExample example = new UserExample();
   example.createCriteria().andNameEqualTo(username);
   List<User> users = this.userDao.selectByExample(example);
   if (users.isEmpty()) {
     throw new IllegalArgumentException(String.format("用户 %s 不存在", username));
   } else {
     return users.get(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;
  }
 private boolean nameExists(String name) {
   UserExample example = new UserExample();
   example.createCriteria().andNameEqualTo(name);
   return this.userDao.selectByExample(example).size() != 0;
 }