@Test public void deleteServerTest() throws SQLException { Server server = Server.builder().id(1L).build(); Assert.assertTrue(serverService.deleteServer(server).getCode() == ServiceResult.SUCCESS); }
public ServiceResult<String> deleteServer(Server server) { try { if (server.getId() == null) { return ServiceResult.fail("server id 为空"); } boolean isSussess = serverDao.getDasClient().execute(() -> { int id = serverDao.deleteServerAndServerConfigByServerId(server.getId()); if (id <= 0) { throw new TransactionException(message.db_message_add_operation_failed); } return true; }); if (isSussess) { return ServiceResult.success(); } } catch (Exception e) { return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); } return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); }
ServerService { public ServiceResult<String> deleteServer(Server server) { try { if (server.getId() == null) { return ServiceResult.fail("server id 为空"); } boolean isSussess = serverDao.getDasClient().execute(() -> { int id = serverDao.deleteServerAndServerConfigByServerId(server.getId()); if (id <= 0) { throw new TransactionException(message.db_message_add_operation_failed); } return true; }); if (isSussess) { return ServiceResult.success(); } } catch (Exception e) { return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); } return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); } }
ServerService { public ServiceResult<String> deleteServer(Server server) { try { if (server.getId() == null) { return ServiceResult.fail("server id 为空"); } boolean isSussess = serverDao.getDasClient().execute(() -> { int id = serverDao.deleteServerAndServerConfigByServerId(server.getId()); if (id <= 0) { throw new TransactionException(message.db_message_add_operation_failed); } return true; }); if (isSussess) { return ServiceResult.success(); } } catch (Exception e) { return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); } return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); }  }
ServerService { public ServiceResult<String> deleteServer(Server server) { try { if (server.getId() == null) { return ServiceResult.fail("server id 为空"); } boolean isSussess = serverDao.getDasClient().execute(() -> { int id = serverDao.deleteServerAndServerConfigByServerId(server.getId()); if (id <= 0) { throw new TransactionException(message.db_message_add_operation_failed); } return true; }); if (isSussess) { return ServiceResult.success(); } } catch (Exception e) { return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); } return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); }  ValidatorChain validatePermision(LoginUser user, Errors errors); ListResult<ServerView> findServerPageList(Paging<Server> paging); ServiceResult insertServer(Server server); ServiceResult<String> deleteServer(Server server); ServiceResult<String> addDataCenter(LoginUser user, Server server); ServiceResult<String> updateDataCenter(LoginUser user, Server server); ServiceResult<String> deleteDataCenter(LoginUser user, Server server); ServiceResult<String> syncDataCenter(LoginUser user, Server server); List<ConfigDataResponse> getCheckData(LoginUser user, Server server); }
ServerService { public ServiceResult<String> deleteServer(Server server) { try { if (server.getId() == null) { return ServiceResult.fail("server id 为空"); } boolean isSussess = serverDao.getDasClient().execute(() -> { int id = serverDao.deleteServerAndServerConfigByServerId(server.getId()); if (id <= 0) { throw new TransactionException(message.db_message_add_operation_failed); } return true; }); if (isSussess) { return ServiceResult.success(); } } catch (Exception e) { return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); } return ServiceResult.fail("deleteServer 删除异常 " + message.db_message_add_operation_failed); }  ValidatorChain validatePermision(LoginUser user, Errors errors); ListResult<ServerView> findServerPageList(Paging<Server> paging); ServiceResult insertServer(Server server); ServiceResult<String> deleteServer(Server server); ServiceResult<String> addDataCenter(LoginUser user, Server server); ServiceResult<String> updateDataCenter(LoginUser user, Server server); ServiceResult<String> deleteDataCenter(LoginUser user, Server server); ServiceResult<String> syncDataCenter(LoginUser user, Server server); List<ConfigDataResponse> getCheckData(LoginUser user, Server server);  }