@Test public void syncdb() throws Exception { String requestJson = JSONObject.toJSONString(DatabaseSet.builder().id(1L).name("name").build()); mockMvc.perform(MockMvcRequestBuilders.post("/project/syncdb") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(requestJson) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); }
@RequestMapping(value = "/syncdb") public ServiceResult<String> syncdb(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors) throws Exception { DasGroup dasGroup = groupDao.getGroupByName(project.getGroupName()); if (dasGroup == null) { return ServiceResult.fail("请先同步组！" + project.getGroupName()); } List<DatabaseSet> list = databaseSetDao.getAllDatabaseSetByNames(StringUtil.toList(project.getDbsetNamees())); if (CollectionUtils.isEmpty(list)) { return ServiceResult.fail("请先同步逻辑库！" + project.getDbsetNamees()); } String dbSetNames = project.getDbsetNamees(); if (dbSetNames.contains(",") && list.size() < dbSetNames.split(",").length) { return ServiceResult.fail("请先同步全部的逻辑库！" + project.getDbsetNamees()); } List<Item> items = list.stream().map(i -> new Item(i.getId(), i.getName())).collect(Collectors.toList()); project.setDal_group_id(dasGroup.getId()); project.setItems(items); return addProject(project, user, errors); }
ProjectController { @RequestMapping(value = "/syncdb") public ServiceResult<String> syncdb(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors) throws Exception { DasGroup dasGroup = groupDao.getGroupByName(project.getGroupName()); if (dasGroup == null) { return ServiceResult.fail("请先同步组！" + project.getGroupName()); } List<DatabaseSet> list = databaseSetDao.getAllDatabaseSetByNames(StringUtil.toList(project.getDbsetNamees())); if (CollectionUtils.isEmpty(list)) { return ServiceResult.fail("请先同步逻辑库！" + project.getDbsetNamees()); } String dbSetNames = project.getDbsetNamees(); if (dbSetNames.contains(",") && list.size() < dbSetNames.split(",").length) { return ServiceResult.fail("请先同步全部的逻辑库！" + project.getDbsetNamees()); } List<Item> items = list.stream().map(i -> new Item(i.getId(), i.getName())).collect(Collectors.toList()); project.setDal_group_id(dasGroup.getId()); project.setItems(items); return addProject(project, user, errors); } }
ProjectController { @RequestMapping(value = "/syncdb") public ServiceResult<String> syncdb(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors) throws Exception { DasGroup dasGroup = groupDao.getGroupByName(project.getGroupName()); if (dasGroup == null) { return ServiceResult.fail("请先同步组！" + project.getGroupName()); } List<DatabaseSet> list = databaseSetDao.getAllDatabaseSetByNames(StringUtil.toList(project.getDbsetNamees())); if (CollectionUtils.isEmpty(list)) { return ServiceResult.fail("请先同步逻辑库！" + project.getDbsetNamees()); } String dbSetNames = project.getDbsetNamees(); if (dbSetNames.contains(",") && list.size() < dbSetNames.split(",").length) { return ServiceResult.fail("请先同步全部的逻辑库！" + project.getDbsetNamees()); } List<Item> items = list.stream().map(i -> new Item(i.getId(), i.getName())).collect(Collectors.toList()); project.setDal_group_id(dasGroup.getId()); project.setItems(items); return addProject(project, user, errors); }  }
ProjectController { @RequestMapping(value = "/syncdb") public ServiceResult<String> syncdb(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors) throws Exception { DasGroup dasGroup = groupDao.getGroupByName(project.getGroupName()); if (dasGroup == null) { return ServiceResult.fail("请先同步组！" + project.getGroupName()); } List<DatabaseSet> list = databaseSetDao.getAllDatabaseSetByNames(StringUtil.toList(project.getDbsetNamees())); if (CollectionUtils.isEmpty(list)) { return ServiceResult.fail("请先同步逻辑库！" + project.getDbsetNamees()); } String dbSetNames = project.getDbsetNamees(); if (dbSetNames.contains(",") && list.size() < dbSetNames.split(",").length) { return ServiceResult.fail("请先同步全部的逻辑库！" + project.getDbsetNamees()); } List<Item> items = list.stream().map(i -> new Item(i.getId(), i.getName())).collect(Collectors.toList()); project.setDal_group_id(dasGroup.getId()); project.setItems(items); return addProject(project, user, errors); }  @RequestMapping(value = "/projects") ServiceResult<List<Project>> getProjects(@RequestParam(value = "name", defaultValue = "") String name); @RequestMapping(value = "/projectsNoGroup") ServiceResult<List<Project>> getProjectsNoGroup(@RequestParam(value = "appGroupId", defaultValue = "0") Long appGroupId); @RequestMapping(value = "/projectsByAppGroupId") ServiceResult<List<Project>> getProjectsByAppGroupId(@RequestParam(value = "appGroupId") Long appGroupId); @RequestMapping(value = "/group") ServiceResult<List<Project>> getGroupProjects(@RequestParam("groupId") Long groupId); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<ProjectView>> getGroupUsers(@RequestBody Paging<ProjectModel> paging, @CurrentUser LoginUser user); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/sync") ServiceResult<String> sync(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/check") ConfigCkeckResult check(@CurrentUser LoginUser user, @RequestParam("id") Long id); @RequestMapping(value = "/syncdb") ServiceResult<String> syncdb(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/generate", method = RequestMethod.POST) ServiceResult generateProject(@CurrentUser LoginUser user, @RequestBody GenerateCodeModel generateCodeRequest); @RequestMapping("/download") String download(@RequestParam(value = "projectId") Long projectId, @CurrentUser LoginUser user, HttpServletResponse response); @RequestMapping("/buttons") ServiceResult getProjectButton(@CurrentUser LoginUser user); }
ProjectController { @RequestMapping(value = "/syncdb") public ServiceResult<String> syncdb(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors) throws Exception { DasGroup dasGroup = groupDao.getGroupByName(project.getGroupName()); if (dasGroup == null) { return ServiceResult.fail("请先同步组！" + project.getGroupName()); } List<DatabaseSet> list = databaseSetDao.getAllDatabaseSetByNames(StringUtil.toList(project.getDbsetNamees())); if (CollectionUtils.isEmpty(list)) { return ServiceResult.fail("请先同步逻辑库！" + project.getDbsetNamees()); } String dbSetNames = project.getDbsetNamees(); if (dbSetNames.contains(",") && list.size() < dbSetNames.split(",").length) { return ServiceResult.fail("请先同步全部的逻辑库！" + project.getDbsetNamees()); } List<Item> items = list.stream().map(i -> new Item(i.getId(), i.getName())).collect(Collectors.toList()); project.setDal_group_id(dasGroup.getId()); project.setItems(items); return addProject(project, user, errors); }  @RequestMapping(value = "/projects") ServiceResult<List<Project>> getProjects(@RequestParam(value = "name", defaultValue = "") String name); @RequestMapping(value = "/projectsNoGroup") ServiceResult<List<Project>> getProjectsNoGroup(@RequestParam(value = "appGroupId", defaultValue = "0") Long appGroupId); @RequestMapping(value = "/projectsByAppGroupId") ServiceResult<List<Project>> getProjectsByAppGroupId(@RequestParam(value = "appGroupId") Long appGroupId); @RequestMapping(value = "/group") ServiceResult<List<Project>> getGroupProjects(@RequestParam("groupId") Long groupId); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<ProjectView>> getGroupUsers(@RequestBody Paging<ProjectModel> paging, @CurrentUser LoginUser user); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/sync") ServiceResult<String> sync(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/check") ConfigCkeckResult check(@CurrentUser LoginUser user, @RequestParam("id") Long id); @RequestMapping(value = "/syncdb") ServiceResult<String> syncdb(@Validated(AddProject.class) @RequestBody Project project, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/generate", method = RequestMethod.POST) ServiceResult generateProject(@CurrentUser LoginUser user, @RequestBody GenerateCodeModel generateCodeRequest); @RequestMapping("/download") String download(@RequestParam(value = "projectId") Long projectId, @CurrentUser LoginUser user, HttpServletResponse response); @RequestMapping("/buttons") ServiceResult getProjectButton(@CurrentUser LoginUser user);  }