class TeamService {

  public List<Team> queryPageList(String owner,
                                  String column,
                                  String order,
                                  int pageNo,
                                  int pageSize) throws Exception {
    LOG.info("queryPageList owner:{}, column:{}, order:{}, pageNo:{}, pageSize:{}",
        owner, column, order, pageNo, pageSize);

    List<Team> list = null;
    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
      TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class);
      Map<String, Object> where = new HashMap<>();
      where.put("owner", owner);
      where.put("column", column);
      where.put("order", order);
      list = teamMapper.selectAll(where, new RowBounds(pageNo, pageSize));

      TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
      // query from team_member table, and set to team
      for (Team team : list) {
        Map<String, Object> whereMember = new HashMap<>();
        whereMember.put("teamId", team.getId());
        List<TeamMember> teamMembers = teamMemberMapper.selectAll(whereMember);
        for (TeamMember teamMember : teamMembers) {
          team.addCollaborator(teamMember);
        }
      }
    } catch (Exception e) {
      LOG.error(e.getMessage(), e);
      throw new Exception(e);
    }
    return list;
  }

}