@Test public void readKeyList() throws Exception { mockMvc.perform((post("/api/device/key_list") .param("device_id", 1129 + "") )).andExpect(status().isOk()) .andDo(print()); }
@RequestMapping(value = "/key_list", method = RequestMethod.POST) public @ResponseBody ResponseHeader readKeyList( @RequestParam(value = "device_id", required = true) int deviceId) { ResponseHeader header = new ResponseHeader(); try { List<Key> keys = cmdDao.queryKeyList(deviceId); if (keys == null || keys.size() == 0) { System.out.println("------start key list request network--------"); keys = apiData.getkeyList(deviceId); cmdDao.insert(keys); } header.setCode(RESPONSE_OK); header.setResult(keys); } catch (Exception e) { e.printStackTrace(); header.setCode(RESPONSE_EXCEPTION); header.setErrorMsg("数据获取异常"); return header; } return header; }
DeviceController { @RequestMapping(value = "/key_list", method = RequestMethod.POST) public @ResponseBody ResponseHeader readKeyList( @RequestParam(value = "device_id", required = true) int deviceId) { ResponseHeader header = new ResponseHeader(); try { List<Key> keys = cmdDao.queryKeyList(deviceId); if (keys == null || keys.size() == 0) { System.out.println("------start key list request network--------"); keys = apiData.getkeyList(deviceId); cmdDao.insert(keys); } header.setCode(RESPONSE_OK); header.setResult(keys); } catch (Exception e) { e.printStackTrace(); header.setCode(RESPONSE_EXCEPTION); header.setErrorMsg("数据获取异常"); return header; } return header; } }
DeviceController { @RequestMapping(value = "/key_list", method = RequestMethod.POST) public @ResponseBody ResponseHeader readKeyList( @RequestParam(value = "device_id", required = true) int deviceId) { ResponseHeader header = new ResponseHeader(); try { List<Key> keys = cmdDao.queryKeyList(deviceId); if (keys == null || keys.size() == 0) { System.out.println("------start key list request network--------"); keys = apiData.getkeyList(deviceId); cmdDao.insert(keys); } header.setCode(RESPONSE_OK); header.setResult(keys); } catch (Exception e) { e.printStackTrace(); header.setCode(RESPONSE_EXCEPTION); header.setErrorMsg("数据获取异常"); return header; } return header; }  }
DeviceController { @RequestMapping(value = "/key_list", method = RequestMethod.POST) public @ResponseBody ResponseHeader readKeyList( @RequestParam(value = "device_id", required = true) int deviceId) { ResponseHeader header = new ResponseHeader(); try { List<Key> keys = cmdDao.queryKeyList(deviceId); if (keys == null || keys.size() == 0) { System.out.println("------start key list request network--------"); keys = apiData.getkeyList(deviceId); cmdDao.insert(keys); } header.setCode(RESPONSE_OK); header.setResult(keys); } catch (Exception e) { e.printStackTrace(); header.setCode(RESPONSE_EXCEPTION); header.setErrorMsg("数据获取异常"); return header; } return header; }  @RequestMapping(value = "/types", method = RequestMethod.GET) @ResponseBody ResponseHeader readDeviceType(); @RequestMapping(value = "/brands", method = RequestMethod.POST) @ResponseBody ResponseHeader readBrands(@RequestParam(value = "type_id", required = true) int typeid); @RequestMapping(value = "/key_test", method = RequestMethod.POST) @ResponseBody ResponseHeader readKeyTests(
            @RequestParam(value = "type_id", required = true) int typeId,
            @RequestParam(value = "brand_id", required = true) int brandId); @RequestMapping(value = "/key_list", method = RequestMethod.POST) @ResponseBody ResponseHeader readKeyList(
            @RequestParam(value = "device_id", required = true) int deviceId); @RequestMapping(value = "/key_data", method = RequestMethod.POST) @ResponseBody ResponseHeader readDeviceKeyData(
            @RequestParam(value = "device_id", required = true) int deviceId,
            @RequestParam(value = "cmd", required = true) String cmd); @RequestMapping(value = "/air_data", method = RequestMethod.POST) @ResponseBody ResponseHeader readAirKeyData(
            @RequestParam(value = "device_id", required = true) int deviceId,
            @RequestParam(value = "cmd", required = true) String cmd,
            @RequestParam(value = "temp", required = true) String temp); }
DeviceController { @RequestMapping(value = "/key_list", method = RequestMethod.POST) public @ResponseBody ResponseHeader readKeyList( @RequestParam(value = "device_id", required = true) int deviceId) { ResponseHeader header = new ResponseHeader(); try { List<Key> keys = cmdDao.queryKeyList(deviceId); if (keys == null || keys.size() == 0) { System.out.println("------start key list request network--------"); keys = apiData.getkeyList(deviceId); cmdDao.insert(keys); } header.setCode(RESPONSE_OK); header.setResult(keys); } catch (Exception e) { e.printStackTrace(); header.setCode(RESPONSE_EXCEPTION); header.setErrorMsg("数据获取异常"); return header; } return header; }  @RequestMapping(value = "/types", method = RequestMethod.GET) @ResponseBody ResponseHeader readDeviceType(); @RequestMapping(value = "/brands", method = RequestMethod.POST) @ResponseBody ResponseHeader readBrands(@RequestParam(value = "type_id", required = true) int typeid); @RequestMapping(value = "/key_test", method = RequestMethod.POST) @ResponseBody ResponseHeader readKeyTests(
            @RequestParam(value = "type_id", required = true) int typeId,
            @RequestParam(value = "brand_id", required = true) int brandId); @RequestMapping(value = "/key_list", method = RequestMethod.POST) @ResponseBody ResponseHeader readKeyList(
            @RequestParam(value = "device_id", required = true) int deviceId); @RequestMapping(value = "/key_data", method = RequestMethod.POST) @ResponseBody ResponseHeader readDeviceKeyData(
            @RequestParam(value = "device_id", required = true) int deviceId,
            @RequestParam(value = "cmd", required = true) String cmd); @RequestMapping(value = "/air_data", method = RequestMethod.POST) @ResponseBody ResponseHeader readAirKeyData(
            @RequestParam(value = "device_id", required = true) int deviceId,
            @RequestParam(value = "cmd", required = true) String cmd,
            @RequestParam(value = "temp", required = true) String temp);  }