From 27dc183f8e88a8d49bdd0852ce96ae2c43738385 Mon Sep 17 00:00:00 2001 From: yyb <1416014977@qq.com> Date: Fri, 16 May 2025 17:09:45 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=A8=B3=E5=AE=9A=E5=B8=81=E6=B5=81?= =?UTF-8?q?=E9=80=9A=E9=87=8F=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jxy-auth/pom.xml | 3 +- jxy-gateway/pom.xml | 3 +- jxy-modules/jxy-binance/pom.xml | 3 +- jxy-modules/jxy-file/pom.xml | 3 +- jxy-modules/jxy-marketall/pom.xml | 3 +- .../jxy/marketall/utils/TestCoingckoApi.java | 107 ++++++++++++++++++ jxy-modules/jxy-order/pom.xml | 3 +- jxy-modules/jxy-strategy/pom.xml | 3 +- jxy-modules/jxy-system/pom.xml | 3 +- jxy-modules/windminer/pom.xml | 3 +- 10 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 jxy-modules/jxy-marketall/src/main/java/com/jxy/marketall/utils/TestCoingckoApi.java diff --git a/jxy-auth/pom.xml b/jxy-auth/pom.xml index 4de2e57..351ed4b 100644 --- a/jxy-auth/pom.xml +++ b/jxy-auth/pom.xml @@ -65,8 +65,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-gateway/pom.xml b/jxy-gateway/pom.xml index 6be9f18..ed925e9 100644 --- a/jxy-gateway/pom.xml +++ b/jxy-gateway/pom.xml @@ -105,8 +105,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-modules/jxy-binance/pom.xml b/jxy-modules/jxy-binance/pom.xml index 68f1a77..a492849 100644 --- a/jxy-modules/jxy-binance/pom.xml +++ b/jxy-modules/jxy-binance/pom.xml @@ -123,8 +123,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-modules/jxy-file/pom.xml b/jxy-modules/jxy-file/pom.xml index b65eaae..d3021e8 100644 --- a/jxy-modules/jxy-file/pom.xml +++ b/jxy-modules/jxy-file/pom.xml @@ -67,8 +67,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-modules/jxy-marketall/pom.xml b/jxy-modules/jxy-marketall/pom.xml index 0512ac2..7fde4b5 100644 --- a/jxy-modules/jxy-marketall/pom.xml +++ b/jxy-modules/jxy-marketall/pom.xml @@ -145,8 +145,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-modules/jxy-marketall/src/main/java/com/jxy/marketall/utils/TestCoingckoApi.java b/jxy-modules/jxy-marketall/src/main/java/com/jxy/marketall/utils/TestCoingckoApi.java new file mode 100644 index 0000000..0d610b2 --- /dev/null +++ b/jxy-modules/jxy-marketall/src/main/java/com/jxy/marketall/utils/TestCoingckoApi.java @@ -0,0 +1,107 @@ +package com.jxy.marketall.utils; + +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.jxy.common.core.utils.DateUtils; +import com.jxy.marketall.dto.CirculatingSupplyDataDto; +import com.jxy.marketall.task.CSupplyTask; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.math.BigDecimal; +import java.net.HttpURLConnection; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.URL; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import static com.jxy.common.core.utils.DateUtils.getZeroTimeOfToday; + +/** + * @Description TODO + * @Date 2025/5/16 09:42 + * @Author yyb + */ +public class TestCoingckoApi { + + private static final Logger log = LoggerFactory.getLogger(CSupplyTask.class); + public static void main(String[] args) { + //String id = "binance-usd"; + //HttpHeaders headers = new HttpHeaders(); + //headers.add("Content-Type","application/json"); + //headers.add("x-cg-demo-api-key","CG-kNuNBTKBcQREBSQKqgj2uua4"); + //headers.add("User-Agent", "Mozilla/5.0"); + //HttpEntity httpEntity = new HttpEntity(null, headers); + //StringBuffer paramsURL = new StringBuffer(API_URL+id); + //String s = HttpUtil.get(paramsURL.toString()); + // + //JSONObject jsonObject = JSONObject.parseObject(s); + ////币种流通量字段 + //JSONObject marketData = jsonObject.getJSONObject("market_data"); + //Date date = null; + //try { + // //币种流通量最后更新时间 + // date = (Date) marketData.get("last_updated"); + //}catch (Exception e){ + // + //} + //double doubleValue = marketData.getDoubleValue("circulating_supply"); + //List circulatingSupplyDataDtos = new ArrayList<>(); + //CirculatingSupplyDataDto circulatingSupplyDataDto = new CirculatingSupplyDataDto(); + //circulatingSupplyDataDto.setValue(BigDecimal.valueOf(doubleValue)); + //circulatingSupplyDataDto.setDate(date); + //circulatingSupplyDataDtos.add(circulatingSupplyDataDto); + //log.info("获取{}币流通量数据成功,最新时间{},流通量{}", id, date, doubleValue); + + + try { + // 配置 HTTP 代理 + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7897)); + + // 创建 URL 对象 + URL url = new URL("https://api.coingecko.com/api/v3/coins/binance-usd"); + + // 打开连接并设置代理 + HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy); + + // 设置请求方法 + connection.setRequestMethod("GET"); + + // 获取响应码 + int responseCode = connection.getResponseCode(); + System.out.println("Response Code: " + responseCode); + + // 读取响应内容 + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + StringBuilder response = new StringBuilder(); + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + JSONObject jsonObject = JSONObject.parseObject(response.toString()); + JSONObject marketData = jsonObject.getJSONObject("market_data"); + double doubleValue = marketData.getDoubleValue("circulating_supply"); + //String dateString = (String) marketData.get("last_updated"); + // 输出响应内容 + System.out.println("doubleValue: " + doubleValue + "date:"+getZeroTimeOfToday()); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static final String[] COINS = {"tether", "usd-coin", "binance-usd"}; + private static final String[] SYMBOLS = {"USDT", "USDC", "BUSD"}; + private static final String API_URL = "https://api.coingecko.com/api/v3/coins/"; + + +} diff --git a/jxy-modules/jxy-order/pom.xml b/jxy-modules/jxy-order/pom.xml index b409027..68b3b04 100644 --- a/jxy-modules/jxy-order/pom.xml +++ b/jxy-modules/jxy-order/pom.xml @@ -129,8 +129,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-modules/jxy-strategy/pom.xml b/jxy-modules/jxy-strategy/pom.xml index 4acdc60..317fe85 100644 --- a/jxy-modules/jxy-strategy/pom.xml +++ b/jxy-modules/jxy-strategy/pom.xml @@ -93,8 +93,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-modules/jxy-system/pom.xml b/jxy-modules/jxy-system/pom.xml index 98e3ff3..95020db 100644 --- a/jxy-modules/jxy-system/pom.xml +++ b/jxy-modules/jxy-system/pom.xml @@ -93,8 +93,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6 diff --git a/jxy-modules/windminer/pom.xml b/jxy-modules/windminer/pom.xml index ad846d3..6f44a31 100644 --- a/jxy-modules/windminer/pom.xml +++ b/jxy-modules/windminer/pom.xml @@ -94,8 +94,9 @@ ${project.artifactId} - org.springframework.boot + org.springframework.boot spring-boot-maven-plugin + 2.5.6