@Test public void delete() throws Exception { ProjectFiles projectFiles = new ProjectFiles(); projectFiles.setFileContent("ProjectServiceTest-FileContent"); projectFiles.setFileName("ProjectServiceTest-FileName"); projectFiles.setCreateBy("ProjectServiceTest-UserName"); Project project = new Project(); project.setDescription("ProjectServiceTest-Description"); project.setName("ProjectServiceTest-ProjectName"); project.setType("PROJECT_TYPE_NOTEBOOK"); project.setUserName("ProjectServiceTest-UserName"); project.setVisibility("PROJECT_VISIBILITY_PRIVATE"); project.setCreateBy("ProjectServiceTest-UserName"); List list = new ArrayList<ProjectFiles>(); list.add(projectFiles); project.setProjectFilesList(list); Boolean ret = projectService.add(project); assertTrue(ret); Boolean deleteRet = projectService.delete(project.getId()); assertTrue(deleteRet); List<Project> projectList = projectService.queryPageList("ProjectServiceTest-UserName", "create_time", "desc", 0, 100); assertEquals(projectList.size(), 0); ProjectFilesService projectFilesService = new ProjectFilesService(); List<ProjectFiles> projectFilesList = projectFilesService.queryList(project.getId()); assertEquals(projectFilesList.size(), 0); }
public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); projectMapper.deleteByPrimaryKey(id); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); ProjectFiles projectFiles = new ProjectFiles(); projectFiles.setProjectId(id); projectFilesMapper.deleteSelective(projectFiles); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }
ProjectService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); projectMapper.deleteByPrimaryKey(id); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); ProjectFiles projectFiles = new ProjectFiles(); projectFiles.setProjectId(id); projectFilesMapper.deleteSelective(projectFiles); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; } }
ProjectService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); projectMapper.deleteByPrimaryKey(id); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); ProjectFiles projectFiles = new ProjectFiles(); projectFiles.setProjectId(id); projectFilesMapper.deleteSelective(projectFiles); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }  }
ProjectService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); projectMapper.deleteByPrimaryKey(id); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); ProjectFiles projectFiles = new ProjectFiles(); projectFiles.setProjectId(id); projectFilesMapper.deleteSelective(projectFiles); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }  List<Project> queryPageList(String userName,
                                     String column,
                                     String order,
                                     int pageNo,
                                     int pageSize); boolean add(Project project); boolean updateByPrimaryKeySelective(Project project); boolean delete(String id); }
ProjectService { public boolean delete(String id) throws Exception { LOG.info("delete({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); projectMapper.deleteByPrimaryKey(id); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); ProjectFiles projectFiles = new ProjectFiles(); projectFiles.setProjectId(id); projectFilesMapper.deleteSelective(projectFiles); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; }  List<Project> queryPageList(String userName,
                                     String column,
                                     String order,
                                     int pageNo,
                                     int pageSize); boolean add(Project project); boolean updateByPrimaryKeySelective(Project project); boolean delete(String id);  }