From 13514082d1d22df2c3bd8b17b54ee354b0432f23 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 08 Jul 2026 11:48:18 +0800
Subject: [PATCH] fix(gateApi): 统一返回成功状态的数据格式

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateConfigDTO.java |   80 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateConfigDTO.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfigDTO.java
new file mode 100644
index 0000000..0c7fa57
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfigDTO.java
@@ -0,0 +1,80 @@
+package com.xcong.excoin.modules.gateApi;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+
+/**
+ * Gate 策略配置 DTO,用于 Web 控制面板参数传递。
+ * apiSecret 不暴露给前端。
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class GateConfigDTO {
+
+    /** API Key */
+    private String apiKey;
+    /** 合约名称,如 ETH_USDT */
+    private String contract;
+    /** 杠杆倍数 */
+    private String leverage;
+    /** 保证金模式:cross / isolated */
+    private String marginMode;
+    /** 持仓模式:single / dual */
+    private String positionMode;
+    /** 网格间距比例 */
+    private BigDecimal gridRate;
+    /** 预期收益(USDT) */
+    private BigDecimal expectedProfit;
+    /** 最大亏损(USDT) */
+    private BigDecimal maxLoss;
+    /** 基底开仓张数 */
+    private String baseQuantity;
+    /** 每次下单张数 */
+    private String quantity;
+    /** 最大持仓张数(单方向),0=不限制 */
+    private int maxPositionSize;
+    /** 止损阶梯次数,0=禁用 */
+    private int stopLossCount;
+    /** 策略重启跨度阈值,0=禁用 */
+    private int restartGridSpan;
+    /** 价格精度 */
+    private int priceScale;
+    /** 合约乘数 */
+    private BigDecimal contractMultiplier;
+    /** 未实现盈亏计价模式:LAST_PRICE / MARK_PRICE */
+    private String unrealizedPnlPriceMode;
+    /** 是否为生产环境 */
+    private boolean isProduction;
+
+    /**
+     * 从 GateConfig 构建 DTO(不暴露 apiSecret)。
+     */
+    public static GateConfigDTO from(GateConfig config) {
+        return GateConfigDTO.builder()
+                .apiKey(config.getApiKey())
+                .contract(config.getContract())
+                .leverage(config.getLeverage())
+                .marginMode(config.getMarginMode())
+                .positionMode(config.getPositionMode())
+                .gridRate(config.getGridRate())
+                .expectedProfit(config.getExpectedProfit())
+                .maxLoss(config.getMaxLoss())
+                .baseQuantity(config.getBaseQuantity())
+                .quantity(config.getQuantity())
+                .maxPositionSize(config.getMaxPositionSize())
+                .stopLossCount(config.getStopLossCount())
+                .restartGridSpan(config.getRestartGridSpan())
+                .priceScale(config.getPriceScale())
+                .contractMultiplier(config.getContractMultiplier())
+                .unrealizedPnlPriceMode(config.getUnrealizedPnlPriceMode() != null
+                        ? config.getUnrealizedPnlPriceMode().name() : "LAST_PRICE")
+                .isProduction(config.isProduction())
+                .build();
+    }
+}

--
Gitblit v1.9.1