@Test public void setDeletedTest() { ListResult<SysDict> listResult = queryTestDictList(); for (SysDict dict : listResult.getRecords()) { Response response = sysDictRestApi.delete(dict.getId(), 1); CommonDataTest.assertResponseSuccess(response); } ListResult<SysDict> listResult2 = queryTestDictList(); for (SysDict dict : listResult2.getRecords()) { assertEquals((int) dict.getDeleted(), 1); } for (SysDict dict : listResult2.getRecords()) { Response response = sysDictRestApi.delete(dict.getId(), 0); CommonDataTest.assertResponseSuccess(response); } ListResult<SysDict> listResult3 = queryTestDictList(); for (SysDict dict : listResult3.getRecords()) { assertEquals((int) dict.getDeleted(), 0); } }
@DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String dictId, @QueryParam("deleted") int deleted) { String msgOperation = "Delete"; if (deleted == 0) { msgOperation = "Restore"; } try { SqlSession sqlSession = MyBatisUtil.getSqlSession(); SysDictMapper sysDictMapper = sqlSession.getMapper(SysDictMapper.class); try { SysDict dict = new SysDict(); dict.setId(dictId); dict.setDeleted(deleted); sysDictMapper.updateBy(dict); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); } finally { sqlSession.close(); } } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " dictionary failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " the dictionary successfully!").success(true).build(); }
SysDictRestApi { @DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String dictId, @QueryParam("deleted") int deleted) { String msgOperation = "Delete"; if (deleted == 0) { msgOperation = "Restore"; } try { SqlSession sqlSession = MyBatisUtil.getSqlSession(); SysDictMapper sysDictMapper = sqlSession.getMapper(SysDictMapper.class); try { SysDict dict = new SysDict(); dict.setId(dictId); dict.setDeleted(deleted); sysDictMapper.updateBy(dict); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); } finally { sqlSession.close(); } } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " dictionary failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " the dictionary successfully!").success(true).build(); } }
SysDictRestApi { @DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String dictId, @QueryParam("deleted") int deleted) { String msgOperation = "Delete"; if (deleted == 0) { msgOperation = "Restore"; } try { SqlSession sqlSession = MyBatisUtil.getSqlSession(); SysDictMapper sysDictMapper = sqlSession.getMapper(SysDictMapper.class); try { SysDict dict = new SysDict(); dict.setId(dictId); dict.setDeleted(deleted); sysDictMapper.updateBy(dict); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); } finally { sqlSession.close(); } } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " dictionary failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " the dictionary successfully!").success(true).build(); } @Inject  SysDictRestApi(); }
SysDictRestApi { @DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String dictId, @QueryParam("deleted") int deleted) { String msgOperation = "Delete"; if (deleted == 0) { msgOperation = "Restore"; } try { SqlSession sqlSession = MyBatisUtil.getSqlSession(); SysDictMapper sysDictMapper = sqlSession.getMapper(SysDictMapper.class); try { SysDict dict = new SysDict(); dict.setId(dictId); dict.setDeleted(deleted); sysDictMapper.updateBy(dict); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); } finally { sqlSession.close(); } } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " dictionary failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " the dictionary successfully!").success(true).build(); } @Inject  SysDictRestApi(); @GET @Path("/list") @SubmarineApi Response list(@QueryParam("dictCode") String dictCode,
                       @QueryParam("dictName") String dictName,
                       @QueryParam("column") String column,
                       @QueryParam("field") String field,
                       @QueryParam("order") String order,
                       @QueryParam("pageNo") int pageNo,
                       @QueryParam("pageSize") int pageSize); @POST @Path("/add") @SubmarineApi Response add(SysDict sysDict); @PUT @Path("/edit") @SubmarineApi Response edit(SysDict sysDict); @DELETE @Path("/delete") @SubmarineApi Response delete(@QueryParam("id") String dictId, @QueryParam("deleted") int deleted); @DELETE @Path("/remove") @SubmarineApi Response remove(String dictId); }
SysDictRestApi { @DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String dictId, @QueryParam("deleted") int deleted) { String msgOperation = "Delete"; if (deleted == 0) { msgOperation = "Restore"; } try { SqlSession sqlSession = MyBatisUtil.getSqlSession(); SysDictMapper sysDictMapper = sqlSession.getMapper(SysDictMapper.class); try { SysDict dict = new SysDict(); dict.setId(dictId); dict.setDeleted(deleted); sysDictMapper.updateBy(dict); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); } finally { sqlSession.close(); } } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " dictionary failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " the dictionary successfully!").success(true).build(); } @Inject  SysDictRestApi(); @GET @Path("/list") @SubmarineApi Response list(@QueryParam("dictCode") String dictCode,
                       @QueryParam("dictName") String dictName,
                       @QueryParam("column") String column,
                       @QueryParam("field") String field,
                       @QueryParam("order") String order,
                       @QueryParam("pageNo") int pageNo,
                       @QueryParam("pageSize") int pageSize); @POST @Path("/add") @SubmarineApi Response add(SysDict sysDict); @PUT @Path("/edit") @SubmarineApi Response edit(SysDict sysDict); @DELETE @Path("/delete") @SubmarineApi Response delete(@QueryParam("id") String dictId, @QueryParam("deleted") int deleted); @DELETE @Path("/remove") @SubmarineApi Response remove(String dictId);  }