SysDictItemRestApi { @DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String id, @QueryParam("deleted") int deleted) { String msgOperation = "Delete"; if (deleted == 0) { msgOperation = "Restore"; } try { SqlSession sqlSession = MyBatisUtil.getSqlSession(); SysDictItemMapper sysDictItemMapper = sqlSession.getMapper(SysDictItemMapper.class); try { SysDictItem dictItem = new SysDictItem(); dictItem.setId(id); dictItem.setDeleted(deleted); sysDictItemMapper.updateBy(dictItem); 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 + " dict item failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message(msgOperation + " the dict item successfully!").success(true).build(); } @Inject  SysDictItemRestApi(); @GET @Path("/list") @SubmarineApi Response list(@QueryParam("dictCode") String dictCode,
                       @QueryParam("itemText") String itemText,
                       @QueryParam("itemValue") String itemValue,
                       @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(SysDictItem sysDictItem); @PUT @Path("/edit") @SubmarineApi Response edit(SysDictItem sysDictItem); @DELETE @Path("/delete") @SubmarineApi Response delete(@QueryParam("id") String id, @QueryParam("deleted") int deleted); @DELETE @Path("/remove") @SubmarineApi Response remove(String id); @GET @Path("/getDictItems/{dictCode}") @SubmarineApi Response getDictItems(@PathParam("dictCode") String dictCode);  }
@Test public void setDeletedTest() { ListResult<SysDictItem> listResult = queryTestDictItemList(); for (SysDictItem item : listResult.getRecords()) { sysDictItemRestApi.delete(item.getId(), 1); } ListResult<SysDictItem> listResult2 = queryTestDictItemList(); for (SysDictItem item : listResult2.getRecords()) { assertEquals((int) item.getDeleted(), 1); } for (SysDictItem item : listResult2.getRecords()) { sysDictItemRestApi.delete(item.getId(), 0); } ListResult<SysDictItem> listResult3 = queryTestDictItemList(); for (SysDictItem item : listResult3.getRecords()) { assertEquals((int) item.getDeleted(), 0); } }