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); 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; }  List<Team> queryPageList(String owner,
                                  String column,
                                  String order,
                                  int pageNo,
                                  int pageSize); boolean add(Team team); boolean updateByPrimaryKeySelective(Team team); boolean delete(String id);  }
@Test public void queryPageList() throws Exception { TeamMember teamMember = new TeamMember(); teamMember.setTeamName("submarine"); teamMember.setInviter(0); teamMember.setMember("admin"); teamMember.setCreateBy("createByteamMember"); Team team = new Team(); team.setTeamName("submarine"); team.setOwner("test_sub"); team.setCreateBy("createByteam"); List list = new ArrayList<TeamMember>(); list.add(teamMember); team.setCollaborators(list); Boolean ret = teamService.add(team); assertTrue(ret); List<Team> teamList = teamService.queryPageList("test_sub", "create_time", "desc", 0, 100); assertEquals(teamList.size(), 1); Team teamDb = teamList.get(0); assertEquals(team.getTeamName(), teamDb.getTeamName()); assertEquals(team.getOwner(), teamDb.getOwner()); assertEquals(team.getCreateBy(), teamDb.getCreateBy()); assertEquals(teamDb.getCollaborators().size(), 1); TeamMember teamMemberDb = teamDb.getCollaborators().get(0); assertEquals(team.getId(), teamMemberDb.getTeamId()); assertEquals(teamMember.getTeamName(), teamMemberDb.getTeamName()); assertEquals(teamMember.getInviter(), teamMemberDb.getInviter()); assertEquals(teamMember.getMember(), teamMemberDb.getMember()); assertEquals(teamMember.getCreateBy(), teamMemberDb.getCreateBy()); }