@Test public void delete() 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); Boolean deleteRet = teamService.delete(team.getId()); assertTrue(deleteRet); List<Team> teamList = teamService.queryPageList("test_sub", "create_time", "desc", 0, 100); assertEquals(teamList.size(), 0); TeamMemberService teamMemberService = new TeamMemberService(); List<TeamMember> teamMemberList = teamMemberService.queryList(team.getId()); assertEquals(teamMemberList.size(), 0); }
public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class); teamMapper.deleteByPrimaryKey(id); TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class); TeamMember teamMember = new TeamMember(); teamMember.setTeamId(id); teamMemberMapper.deleteSelective(teamMember); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }
TeamService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class); teamMapper.deleteByPrimaryKey(id); TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class); TeamMember teamMember = new TeamMember(); teamMember.setTeamId(id); teamMemberMapper.deleteSelective(teamMember); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; } }
TeamService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class); teamMapper.deleteByPrimaryKey(id); TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class); TeamMember teamMember = new TeamMember(); teamMember.setTeamId(id); teamMemberMapper.deleteSelective(teamMember); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }  }
TeamService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class); teamMapper.deleteByPrimaryKey(id); TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class); TeamMember teamMember = new TeamMember(); teamMember.setTeamId(id); teamMemberMapper.deleteSelective(teamMember); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }  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); }
TeamService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class); teamMapper.deleteByPrimaryKey(id); TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class); TeamMember teamMember = new TeamMember(); teamMember.setTeamId(id); teamMemberMapper.deleteSelective(teamMember); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }  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);  }