| | |
| | | return authTokenDTO; |
| | | } |
| | | |
| | | public CommonResult<JSONObject> handleHttp(String method, String url, Map<String, Object> params) { |
| | | JSONObject data = new JSONObject(); |
| | | String resp = null; |
| | | try { |
| | | String upperMethod = method.toUpperCase(); |
| | | if ("GET".equals(upperMethod)) { |
| | | resp = IailabHttpUtils.doGet(url, params, CHARSET); |
| | | } else if ("POST".equals(upperMethod)) { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | resp = IailabHttpUtils.doPost(url, objectMapper.writeValueAsString(params), CHARSET); |
| | | } |
| | | if (StringUtils.isEmpty(resp)) { |
| | | return CommonResult.error(GlobalErrorCodeConstants.EMPTY_RESP); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(resp); |
| | | Integer respCode = jsonObject.getInteger(RESP_CODE); |
| | | if (!GlobalErrorCodeConstants.SUCCESS.getCode().equals(respCode)) { |
| | | CommonResult.error(respCode, jsonObject.getString(RESP_MSG)); |
| | | } |
| | | data = jsonObject.getJSONObject(RESP_DATA); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(), ex.getMessage()); |
| | | } |
| | | return CommonResult.success(data); |
| | | } |
| | | |
| | | /** |
| | | * 查询多个测点当前值 |
| | | * |