@Test public void queryPageList() 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); List<Project> projectList = projectService.queryPageList("ProjectServiceTest-UserName", "create_time", "desc", 0, 100); assertEquals(projectList.size(), 1); Project projectDb = projectList.get(0); assertEquals(project.getDescription(), projectDb.getDescription()); assertEquals(project.getName(), projectDb.getName()); assertEquals(project.getType(), projectDb.getType()); assertEquals(project.getUserName(), projectDb.getUserName()); assertEquals(project.getVisibility(), projectDb.getVisibility()); assertEquals(project.getCreateBy(), projectDb.getCreateBy()); assertEquals(projectDb.getProjectFilesList().size(), 1); ProjectFiles projectFilesDb = projectDb.getProjectFilesList().get(0); assertEquals(project.getId(), projectFilesDb.getProjectId()); assertEquals(projectFiles.getFileContent(), projectFilesDb.getFileContent()); assertEquals(projectFiles.getFileName(), projectFilesDb.getFileName()); assertEquals(projectFiles.getCreateBy(), projectFilesDb.getCreateBy()); }
public List<Project> queryPageList(String userName, String column, String order, int pageNo, int pageSize) throws Exception { LOG.info("queryPageList owner:{}, column:{}, order:{}, pageNo:{}, pageSize:{}", userName, column, order, pageNo, pageSize); List<Project> list = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); Map<String, Object> where = new HashMap<>(); where.put("userName", userName); where.put("column", column); where.put("order", order); list = projectMapper.selectAll(where, new RowBounds(pageNo, pageSize)); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); for (Project project : list) { Map<String, Object> whereMember = new HashMap<>(); whereMember.put("projectId", project.getId()); List<ProjectFiles> projectFilesList = projectFilesMapper.selectAll(whereMember); for (ProjectFiles projectFiles : projectFilesList) { project.addProjectFilesList(projectFiles); } } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return list; }
ProjectService { public List<Project> queryPageList(String userName, String column, String order, int pageNo, int pageSize) throws Exception { LOG.info("queryPageList owner:{}, column:{}, order:{}, pageNo:{}, pageSize:{}", userName, column, order, pageNo, pageSize); List<Project> list = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); Map<String, Object> where = new HashMap<>(); where.put("userName", userName); where.put("column", column); where.put("order", order); list = projectMapper.selectAll(where, new RowBounds(pageNo, pageSize)); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); for (Project project : list) { Map<String, Object> whereMember = new HashMap<>(); whereMember.put("projectId", project.getId()); List<ProjectFiles> projectFilesList = projectFilesMapper.selectAll(whereMember); for (ProjectFiles projectFiles : projectFilesList) { project.addProjectFilesList(projectFiles); } } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return list; } }
ProjectService { public List<Project> queryPageList(String userName, String column, String order, int pageNo, int pageSize) throws Exception { LOG.info("queryPageList owner:{}, column:{}, order:{}, pageNo:{}, pageSize:{}", userName, column, order, pageNo, pageSize); List<Project> list = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); Map<String, Object> where = new HashMap<>(); where.put("userName", userName); where.put("column", column); where.put("order", order); list = projectMapper.selectAll(where, new RowBounds(pageNo, pageSize)); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); for (Project project : list) { Map<String, Object> whereMember = new HashMap<>(); whereMember.put("projectId", project.getId()); List<ProjectFiles> projectFilesList = projectFilesMapper.selectAll(whereMember); for (ProjectFiles projectFiles : projectFilesList) { project.addProjectFilesList(projectFiles); } } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return list; }  }
ProjectService { public List<Project> queryPageList(String userName, String column, String order, int pageNo, int pageSize) throws Exception { LOG.info("queryPageList owner:{}, column:{}, order:{}, pageNo:{}, pageSize:{}", userName, column, order, pageNo, pageSize); List<Project> list = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); Map<String, Object> where = new HashMap<>(); where.put("userName", userName); where.put("column", column); where.put("order", order); list = projectMapper.selectAll(where, new RowBounds(pageNo, pageSize)); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); for (Project project : list) { Map<String, Object> whereMember = new HashMap<>(); whereMember.put("projectId", project.getId()); List<ProjectFiles> projectFilesList = projectFilesMapper.selectAll(whereMember); for (ProjectFiles projectFiles : projectFilesList) { project.addProjectFilesList(projectFiles); } } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return list; }  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 List<Project> queryPageList(String userName, String column, String order, int pageNo, int pageSize) throws Exception { LOG.info("queryPageList owner:{}, column:{}, order:{}, pageNo:{}, pageSize:{}", userName, column, order, pageNo, pageSize); List<Project> list = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { ProjectMapper projectMapper = sqlSession.getMapper(ProjectMapper.class); Map<String, Object> where = new HashMap<>(); where.put("userName", userName); where.put("column", column); where.put("order", order); list = projectMapper.selectAll(where, new RowBounds(pageNo, pageSize)); ProjectFilesMapper projectFilesMapper = sqlSession.getMapper(ProjectFilesMapper.class); for (Project project : list) { Map<String, Object> whereMember = new HashMap<>(); whereMember.put("projectId", project.getId()); List<ProjectFiles> projectFilesList = projectFilesMapper.selectAll(whereMember); for (ProjectFiles projectFiles : projectFilesList) { project.addProjectFilesList(projectFiles); } } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return list; }  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);  }