From b79c0fa3aa4f7dffe18ab419b6cf4ed47ebd22f9 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期二, 27 八月 2024 17:33:37 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 109 insertions(+), 0 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java index 350cca0..3327e7d 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java @@ -117,4 +117,113 @@ } return ""; } + + + + public static String getSeriesById(String brandId) throws Exception { + // Create a new request. + Request httpClientRequest = new Request(); + try { + // Set the request parameters. + // AppKey, AppSecrect, Method and Url are required parameters. + // Directly writing AK/SK in code is risky. For security, encrypt your AK/SK and store them in the configuration file or environment variables. + // In this example, the AK/SK are stored in environment variables for identity authentication. + // Before running this example, set environment variables HUAWEICLOUD_SDK_AK and HUAWEICLOUD_SDK_SK. + httpClientRequest.setKey("9a4a2b69afe141718f6843c5d39961ec"); + httpClientRequest.setSecret("541845f206324bbc933065b44fc98c47"); + httpClientRequest.setMethod("POST"); + // Set a request URL in the format of https://{Endpoint}/{URI}. + httpClientRequest.setUrl("https://vehiclequery.apistore.huaweicloud.com/vehicle/query/model"); + httpClientRequest.addHeader("Content-Type", "text/plain"); + httpClientRequest.addQueryStringParam("seriesId",brandId); + // Set a body for http request. +// httpClientRequest.setBody("put your request body here"); + } catch (Exception e) { +// LOGGER.error(e.getMessage()); + return ""; + } + CloseableHttpClient client = null; + try { + // Sign the request. + HttpRequestBase signedRequest = Client.sign(httpClientRequest, Constant.SIGNATURE_ALGORITHM_SDK_HMAC_SHA256); + if (Constant.DO_VERIFY) { + // creat httpClient and verify ssl certificate + HostName.setUrlHostName(httpClientRequest.getHost()); + client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClientWithVerify(Constant.INTERNATIONAL_PROTOCOL); + } else { + // creat httpClient and do not verify ssl certificate + client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClient(Constant.INTERNATIONAL_PROTOCOL); + } + HttpResponse response = client.execute(signedRequest); + // Print the body of the response. + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { +// LOGGER.info("Processing Body with name: {} and value: {}", System.getProperty("line.separator"), +// EntityUtils.toString(resEntity, "UTF-8")); + String string = EntityUtils.toString(resEntity, "UTF-8"); + return string; + } + } catch (Exception e) { + LOGGER.error(e.getMessage()); + } finally { + if (client != null) { + client.close(); + } + } + return ""; + } + + + public static String getDetailById(String brandId) throws Exception { + // Create a new request. + Request httpClientRequest = new Request(); + try { + // Set the request parameters. + // AppKey, AppSecrect, Method and Url are required parameters. + // Directly writing AK/SK in code is risky. For security, encrypt your AK/SK and store them in the configuration file or environment variables. + // In this example, the AK/SK are stored in environment variables for identity authentication. + // Before running this example, set environment variables HUAWEICLOUD_SDK_AK and HUAWEICLOUD_SDK_SK. + httpClientRequest.setKey("9a4a2b69afe141718f6843c5d39961ec"); + httpClientRequest.setSecret("541845f206324bbc933065b44fc98c47"); + httpClientRequest.setMethod("POST"); + // Set a request URL in the format of https://{Endpoint}/{URI}. + httpClientRequest.setUrl("https://vehiclequery.apistore.huaweicloud.com/vehicle/query/detail"); + httpClientRequest.addHeader("Content-Type", "text/plain"); + httpClientRequest.addQueryStringParam("modelId",brandId); + // Set a body for http request. +// httpClientRequest.setBody("put your request body here"); + } catch (Exception e) { +// LOGGER.error(e.getMessage()); + return ""; + } + CloseableHttpClient client = null; + try { + // Sign the request. + HttpRequestBase signedRequest = Client.sign(httpClientRequest, Constant.SIGNATURE_ALGORITHM_SDK_HMAC_SHA256); + if (Constant.DO_VERIFY) { + // creat httpClient and verify ssl certificate + HostName.setUrlHostName(httpClientRequest.getHost()); + client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClientWithVerify(Constant.INTERNATIONAL_PROTOCOL); + } else { + // creat httpClient and do not verify ssl certificate + client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClient(Constant.INTERNATIONAL_PROTOCOL); + } + HttpResponse response = client.execute(signedRequest); + // Print the body of the response. + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { +// LOGGER.info("Processing Body with name: {} and value: {}", System.getProperty("line.separator"), +// EntityUtils.toString(resEntity, "UTF-8")); + String string = EntityUtils.toString(resEntity, "UTF-8"); + return string; + } + } catch (Exception e) { + LOGGER.error(e.getMessage()); + } finally { + if (client != null) { + client.close(); + } + } + return ""; + } } -- Gitblit v1.7.1