@Test public void delete() throws Exception { String requestJson = JSONObject.toJSONString(DatabaseSetEntry.builder().id(1L).name("name").build()); mockMvc.perform(MockMvcRequestBuilders.delete("/groupdbSetEntry/delete") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(requestJson) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); }
@RequestMapping(value = "/delete", method = RequestMethod.DELETE) public ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors) throws Exception { ValidateResult validateRes = databaseSetService.validatePermision(user, errors) .addAssert(() -> databaseSetEntryService.deleteDataCenter(user, dbsetEntry)) .addAssert(() -> dataBaseSetEntryDao.deleteDatabaseSetEntryById(dbsetEntry.getId()) > 0, message.db_message_delete_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }
DatabaseSetEntryController { @RequestMapping(value = "/delete", method = RequestMethod.DELETE) public ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors) throws Exception { ValidateResult validateRes = databaseSetService.validatePermision(user, errors) .addAssert(() -> databaseSetEntryService.deleteDataCenter(user, dbsetEntry)) .addAssert(() -> dataBaseSetEntryDao.deleteDatabaseSetEntryById(dbsetEntry.getId()) > 0, message.db_message_delete_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); } }
DatabaseSetEntryController { @RequestMapping(value = "/delete", method = RequestMethod.DELETE) public ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors) throws Exception { ValidateResult validateRes = databaseSetService.validatePermision(user, errors) .addAssert(() -> databaseSetEntryService.deleteDataCenter(user, dbsetEntry)) .addAssert(() -> dataBaseSetEntryDao.deleteDatabaseSetEntryById(dbsetEntry.getId()) > 0, message.db_message_delete_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }  }
DatabaseSetEntryController { @RequestMapping(value = "/delete", method = RequestMethod.DELETE) public ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors) throws Exception { ValidateResult validateRes = databaseSetService.validatePermision(user, errors) .addAssert(() -> databaseSetEntryService.deleteDataCenter(user, dbsetEntry)) .addAssert(() -> dataBaseSetEntryDao.deleteDatabaseSetEntryById(dbsetEntry.getId()) > 0, message.db_message_delete_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }  @RequestMapping(value = "/{dbsetId}/list") ServiceResult<List<DatabaseSetEntry>> list(@PathVariable("dbsetId") Long dbsetId); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<DatabaseSetEntryView>> loadPageList(@RequestBody Paging<DatabaseSetEntry> paging); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/adds", method = RequestMethod.POST) ServiceResult<String> adds(@Validated(AddDbSetEntry.class) @RequestBody List<DatabaseSetEntry> list, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/sync") ServiceResult<String> sync(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/check") ConfigCkeckResult check(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/syncdb") ServiceResult<String> syncdb(@Validated(AddDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping("/buttons") ServiceResult getProjectButton(@CurrentUser LoginUser user); }
DatabaseSetEntryController { @RequestMapping(value = "/delete", method = RequestMethod.DELETE) public ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors) throws Exception { ValidateResult validateRes = databaseSetService.validatePermision(user, errors) .addAssert(() -> databaseSetEntryService.deleteDataCenter(user, dbsetEntry)) .addAssert(() -> dataBaseSetEntryDao.deleteDatabaseSetEntryById(dbsetEntry.getId()) > 0, message.db_message_delete_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }  @RequestMapping(value = "/{dbsetId}/list") ServiceResult<List<DatabaseSetEntry>> list(@PathVariable("dbsetId") Long dbsetId); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<DatabaseSetEntryView>> loadPageList(@RequestBody Paging<DatabaseSetEntry> paging); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/adds", method = RequestMethod.POST) ServiceResult<String> adds(@Validated(AddDbSetEntry.class) @RequestBody List<DatabaseSetEntry> list, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/sync") ServiceResult<String> sync(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/check") ConfigCkeckResult check(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/syncdb") ServiceResult<String> syncdb(@Validated(AddDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping("/buttons") ServiceResult getProjectButton(@CurrentUser LoginUser user);  }