Ver Fonte

增加查询钱包链接口 /Wallet/QueryWalletChains

muchinfo há 1 mês atrás
pai
commit
2634b5fe3d
7 ficheiros alterados com 567 adições e 0 exclusões
  1. 42 0
      controllers/wallet/chain.go
  2. 167 0
      docs/docs.go
  3. 167 0
      docs/swagger.json
  4. 118 0
      docs/swagger.yaml
  5. 45 0
      models/ori.go
  6. 27 0
      models/wallet.go
  7. 1 0
      routers/router.go

+ 42 - 0
controllers/wallet/chain.go

@@ -0,0 +1,42 @@
+package wallet
+
+import (
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"mtp2_if/models"
+	"net/http"
+
+	"github.com/gin-gonic/gin"
+)
+
+type QueryWalletChainsReq struct {
+	ChannelCode string `form:"channelCode" binding:"required"` // 渠道代码
+}
+
+// QueryWalletChains
+// @Summary  查询钱包链
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param    channelCode query    string true "渠道代码"
+// @Success  200         {array}  models.WalletChainRsp
+// @Failure  500         {object} app.Response
+// @Router   /Wallet/QueryWalletChains [get]
+// @Tags     钱包
+func QueryWalletChains(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryWalletChainsReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryWalletChains failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	if rsp, err := models.GetWalletChains(req.ChannelCode); err == nil {
+		appG.Response(http.StatusOK, e.SUCCESS, rsp)
+	} else {
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 167 - 0
docs/docs.go

@@ -21267,6 +21267,48 @@ const docTemplate = `{
                 }
             }
         },
+        "/Wallet/QueryWalletChains": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "钱包"
+                ],
+                "summary": "查询钱包链",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "渠道代码",
+                        "name": "channelCode",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WalletChainRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/InsertXhcpSellBackApply": {
             "post": {
                 "security": [
@@ -61434,6 +61476,131 @@ const docTemplate = `{
                 }
             }
         },
+        "models.WalletChainRsp": {
+            "type": "object",
+            "properties": {
+                "chain_id": {
+                    "description": "链ID",
+                    "type": "string"
+                },
+                "chain_identifier": {
+                    "description": "链标识符",
+                    "type": "string"
+                },
+                "channel_code": {
+                    "description": "渠道代码",
+                    "type": "string"
+                },
+                "coinbase_maturity": {
+                    "description": "在 Coinbase 交易被视为成熟并可以使用之前所需的确认次数,例如 BTC 需要 100 次确认。",
+                    "type": "integer"
+                },
+                "confirming_threshold": {
+                    "description": "确认阈值,链上交易所需的确认次数,例如以太坊为 64 次",
+                    "type": "integer"
+                },
+                "enabled": {
+                    "description": "是否启用,0-不启用;1-启用",
+                    "type": "integer"
+                },
+                "explorer_address_url": {
+                    "description": "区块链浏览器上的地址 URL 模式",
+                    "type": "string"
+                },
+                "explorer_tx_url": {
+                    "description": "区块链浏览器上的交易 URL 模式",
+                    "type": "string"
+                },
+                "icon_url": {
+                    "description": "链条图标的 URL",
+                    "type": "string"
+                },
+                "id": {
+                    "description": "sep",
+                    "type": "integer"
+                },
+                "require_memo": {
+                    "description": "该链条是否需要备注",
+                    "type": "integer"
+                },
+                "tokens": {
+                    "description": "链支持的代币列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Wallettokens"
+                    }
+                }
+            }
+        },
+        "models.Wallettokens": {
+            "type": "object",
+            "properties": {
+                "asset_id": {
+                    "description": "资产 ID,关联交易所账户中持有资产的唯一标识符",
+                    "type": "string"
+                },
+                "asset_model_type": {
+                    "description": "模型类型",
+                    "type": "string"
+                },
+                "can_deposit": {
+                    "description": "是否可以充值",
+                    "type": "integer"
+                },
+                "can_withdraw": {
+                    "description": "是否可以提现",
+                    "type": "integer"
+                },
+                "chain_id": {
+                    "description": "所属链ID",
+                    "type": "string"
+                },
+                "channel_code": {
+                    "description": "渠道ID",
+                    "type": "string"
+                },
+                "deposit_threshold": {
+                    "description": "最低充值金额",
+                    "type": "string"
+                },
+                "dust_threshold": {
+                    "description": "最低提现金额",
+                    "type": "string"
+                },
+                "enabled": {
+                    "description": "是否可用,0-不可用;1-可用",
+                    "type": "integer"
+                },
+                "fee_token_id": {
+                    "description": "手续费代币ID",
+                    "type": "string"
+                },
+                "icon_url": {
+                    "description": "代币图标URL",
+                    "type": "string"
+                },
+                "id": {
+                    "description": "SEQ_WALLET_TOKENS",
+                    "type": "integer"
+                },
+                "name": {
+                    "description": "代币全名",
+                    "type": "string"
+                },
+                "symbol": {
+                    "description": "代币符号",
+                    "type": "string"
+                },
+                "token_decimal": {
+                    "description": "小数位",
+                    "type": "integer"
+                },
+                "token_id": {
+                    "description": "代币ID",
+                    "type": "string"
+                }
+            }
+        },
         "models.Warehouseinfo": {
             "type": "object",
             "required": [

+ 167 - 0
docs/swagger.json

@@ -21258,6 +21258,48 @@
                 }
             }
         },
+        "/Wallet/QueryWalletChains": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "钱包"
+                ],
+                "summary": "查询钱包链",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "渠道代码",
+                        "name": "channelCode",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WalletChainRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/InsertXhcpSellBackApply": {
             "post": {
                 "security": [
@@ -61425,6 +61467,131 @@
                 }
             }
         },
+        "models.WalletChainRsp": {
+            "type": "object",
+            "properties": {
+                "chain_id": {
+                    "description": "链ID",
+                    "type": "string"
+                },
+                "chain_identifier": {
+                    "description": "链标识符",
+                    "type": "string"
+                },
+                "channel_code": {
+                    "description": "渠道代码",
+                    "type": "string"
+                },
+                "coinbase_maturity": {
+                    "description": "在 Coinbase 交易被视为成熟并可以使用之前所需的确认次数,例如 BTC 需要 100 次确认。",
+                    "type": "integer"
+                },
+                "confirming_threshold": {
+                    "description": "确认阈值,链上交易所需的确认次数,例如以太坊为 64 次",
+                    "type": "integer"
+                },
+                "enabled": {
+                    "description": "是否启用,0-不启用;1-启用",
+                    "type": "integer"
+                },
+                "explorer_address_url": {
+                    "description": "区块链浏览器上的地址 URL 模式",
+                    "type": "string"
+                },
+                "explorer_tx_url": {
+                    "description": "区块链浏览器上的交易 URL 模式",
+                    "type": "string"
+                },
+                "icon_url": {
+                    "description": "链条图标的 URL",
+                    "type": "string"
+                },
+                "id": {
+                    "description": "sep",
+                    "type": "integer"
+                },
+                "require_memo": {
+                    "description": "该链条是否需要备注",
+                    "type": "integer"
+                },
+                "tokens": {
+                    "description": "链支持的代币列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Wallettokens"
+                    }
+                }
+            }
+        },
+        "models.Wallettokens": {
+            "type": "object",
+            "properties": {
+                "asset_id": {
+                    "description": "资产 ID,关联交易所账户中持有资产的唯一标识符",
+                    "type": "string"
+                },
+                "asset_model_type": {
+                    "description": "模型类型",
+                    "type": "string"
+                },
+                "can_deposit": {
+                    "description": "是否可以充值",
+                    "type": "integer"
+                },
+                "can_withdraw": {
+                    "description": "是否可以提现",
+                    "type": "integer"
+                },
+                "chain_id": {
+                    "description": "所属链ID",
+                    "type": "string"
+                },
+                "channel_code": {
+                    "description": "渠道ID",
+                    "type": "string"
+                },
+                "deposit_threshold": {
+                    "description": "最低充值金额",
+                    "type": "string"
+                },
+                "dust_threshold": {
+                    "description": "最低提现金额",
+                    "type": "string"
+                },
+                "enabled": {
+                    "description": "是否可用,0-不可用;1-可用",
+                    "type": "integer"
+                },
+                "fee_token_id": {
+                    "description": "手续费代币ID",
+                    "type": "string"
+                },
+                "icon_url": {
+                    "description": "代币图标URL",
+                    "type": "string"
+                },
+                "id": {
+                    "description": "SEQ_WALLET_TOKENS",
+                    "type": "integer"
+                },
+                "name": {
+                    "description": "代币全名",
+                    "type": "string"
+                },
+                "symbol": {
+                    "description": "代币符号",
+                    "type": "string"
+                },
+                "token_decimal": {
+                    "description": "小数位",
+                    "type": "integer"
+                },
+                "token_id": {
+                    "description": "代币ID",
+                    "type": "string"
+                }
+            }
+        },
         "models.Warehouseinfo": {
             "type": "object",
             "required": [

+ 118 - 0
docs/swagger.yaml

@@ -27278,6 +27278,98 @@ definitions:
         description: 商品
         type: string
     type: object
+  models.WalletChainRsp:
+    properties:
+      chain_id:
+        description: 链ID
+        type: string
+      chain_identifier:
+        description: 链标识符
+        type: string
+      channel_code:
+        description: 渠道代码
+        type: string
+      coinbase_maturity:
+        description: 在 Coinbase 交易被视为成熟并可以使用之前所需的确认次数,例如 BTC 需要 100 次确认。
+        type: integer
+      confirming_threshold:
+        description: 确认阈值,链上交易所需的确认次数,例如以太坊为 64 次
+        type: integer
+      enabled:
+        description: 是否启用,0-不启用;1-启用
+        type: integer
+      explorer_address_url:
+        description: 区块链浏览器上的地址 URL 模式
+        type: string
+      explorer_tx_url:
+        description: 区块链浏览器上的交易 URL 模式
+        type: string
+      icon_url:
+        description: 链条图标的 URL
+        type: string
+      id:
+        description: sep
+        type: integer
+      require_memo:
+        description: 该链条是否需要备注
+        type: integer
+      tokens:
+        description: 链支持的代币列表
+        items:
+          $ref: '#/definitions/models.Wallettokens'
+        type: array
+    type: object
+  models.Wallettokens:
+    properties:
+      asset_id:
+        description: 资产 ID,关联交易所账户中持有资产的唯一标识符
+        type: string
+      asset_model_type:
+        description: 模型类型
+        type: string
+      can_deposit:
+        description: 是否可以充值
+        type: integer
+      can_withdraw:
+        description: 是否可以提现
+        type: integer
+      chain_id:
+        description: 所属链ID
+        type: string
+      channel_code:
+        description: 渠道ID
+        type: string
+      deposit_threshold:
+        description: 最低充值金额
+        type: string
+      dust_threshold:
+        description: 最低提现金额
+        type: string
+      enabled:
+        description: 是否可用,0-不可用;1-可用
+        type: integer
+      fee_token_id:
+        description: 手续费代币ID
+        type: string
+      icon_url:
+        description: 代币图标URL
+        type: string
+      id:
+        description: SEQ_WALLET_TOKENS
+        type: integer
+      name:
+        description: 代币全名
+        type: string
+      symbol:
+        description: 代币符号
+        type: string
+      token_decimal:
+        description: 小数位
+        type: integer
+      token_id:
+        description: 代币ID
+        type: string
+    type: object
   models.Warehouseinfo:
     properties:
       address:
@@ -46160,6 +46252,32 @@ paths:
       summary: 查询钱包地址
       tags:
       - 钱包
+  /Wallet/QueryWalletChains:
+    get:
+      parameters:
+      - description: 渠道代码
+        in: query
+        name: channelCode
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WalletChainRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询钱包链
+      tags:
+      - 钱包
   /WrTrade2/InsertXhcpSellBackApply:
     post:
       parameters:

+ 45 - 0
models/ori.go

@@ -1444,3 +1444,48 @@ type Walletaddress struct {
 func (r *Walletaddress) TableName() string {
 	return "WALLET_ADDRESS"
 }
+
+// Walletchains 数字钱包渠道链表
+type Walletchains struct {
+	ID                   int32  `json:"id" xorm:"ID"`                                     // sep
+	CHANNEL_CODE         string `json:"channel_code" xorm:"CHANNEL_CODE"`                 // 渠道代码
+	CHAIN_ID             string `json:"chain_id" xorm:"CHAIN_ID"`                         // 链ID
+	ICON_URL             string `json:"icon_url" xorm:"ICON_URL"`                         // 链条图标的 URL
+	CHAIN_IDENTIFIER     string `json:"chain_identifier" xorm:"CHAIN_IDENTIFIER"`         // 链标识符
+	EXPLORER_TX_URL      string `json:"explorer_tx_url" xorm:"EXPLORER_TX_URL"`           // 区块链浏览器上的交易 URL 模式
+	EXPLORER_ADDRESS_URL string `json:"explorer_address_url" xorm:"EXPLORER_ADDRESS_URL"` // 区块链浏览器上的地址 URL 模式
+	REQUIRE_MEMO         int32  `json:"require_memo" xorm:"REQUIRE_MEMO"`                 // 该链条是否需要备注
+	CONFIRMING_THRESHOLD int32  `json:"confirming_threshold" xorm:"CONFIRMING_THRESHOLD"` // 确认阈值,链上交易所需的确认次数,例如以太坊为 64 次
+	COINBASE_MATURITY    int32  `json:"coinbase_maturity" xorm:"COINBASE_MATURITY"`       // 在 Coinbase 交易被视为成熟并可以使用之前所需的确认次数,例如 BTC 需要 100 次确认。
+	ENABLED              int32  `json:"enabled" xorm:"ENABLED"`                           // 是否启用,0-不启用;1-启用
+}
+
+// TableName is WALLET_CHAINS
+func (r *Walletchains) TableName() string {
+	return "WALLET_CHAINS"
+}
+
+// Wallettokens 数字钱包代币信息表
+type Wallettokens struct {
+	ID                int32  `json:"id" xorm:"ID"`                               // SEQ_WALLET_TOKENS
+	CHANNEL_CODE      string `json:"channel_code" xorm:"CHANNEL_CODE"`           // 渠道ID
+	CHAIN_ID          string `json:"chain_id" xorm:"CHAIN_ID"`                   // 所属链ID
+	TOKEN_ID          string `json:"token_id" xorm:"TOKEN_ID"`                   // 代币ID
+	ASSET_ID          string `json:"asset_id" xorm:"ASSET_ID"`                   // 资产 ID,关联交易所账户中持有资产的唯一标识符
+	SYMBOL            string `json:"symbol" xorm:"SYMBOL"`                       // 代币符号
+	NAME              string `json:"name" xorm:"NAME"`                           // 代币全名
+	TOKEN_DECIMAL     int32  `json:"token_decimal" xorm:"TOKEN_DECIMAL"`         // 小数位
+	ICON_URL          string `json:"icon_url" xorm:"ICON_URL"`                   // 代币图标URL
+	FEE_TOKEN_ID      string `json:"fee_token_id" xorm:"FEE_TOKEN_ID"`           // 手续费代币ID
+	CAN_DEPOSIT       int32  `json:"can_deposit" xorm:"CAN_DEPOSIT"`             // 是否可以充值
+	CAN_WITHDRAW      int32  `json:"can_withdraw" xorm:"CAN_WITHDRAW"`           // 是否可以提现
+	DUST_THRESHOLD    string `json:"dust_threshold" xorm:"DUST_THRESHOLD"`       // 最低提现金额
+	DEPOSIT_THRESHOLD string `json:"deposit_threshold" xorm:"DEPOSIT_THRESHOLD"` // 最低充值金额
+	ASSET_MODEL_TYPE  string `json:"asset_model_type" xorm:"ASSET_MODEL_TYPE"`   // 模型类型
+	ENABLED           int32  `json:"enabled" xorm:"ENABLED"`                     // 是否可用,0-不可用;1-可用
+}
+
+// TableName is WALLET_TOKENS
+func (r *Wallettokens) TableName() string {
+	return "WALLET_TOKENS"
+}

+ 27 - 0
models/wallet.go

@@ -48,3 +48,30 @@ func (r *DigitalWalletAddress) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+type WalletChainRsp struct {
+	Walletchains
+	Tokens []Wallettokens `json:"tokens"` // 链支持的代币列表
+}
+
+func GetWalletChains(channelCode string) ([]WalletChainRsp, error) {
+	rsp := make([]WalletChainRsp, 0)
+	datas := make([]Walletchains, 0)
+	err := db.GetEngine().Where("CHANNEL_CODE = ?", channelCode).Find(&datas)
+	if err != nil {
+		return nil, err
+	}
+	for i := range datas {
+		tokens := make([]Wallettokens, 0)
+		err = db.GetEngine().Where("CHANNEL_CODE = ? AND CHAIN_ID = ?", channelCode, datas[i].CHAIN_ID).Find(&tokens)
+		if err != nil {
+			return nil, err
+		}
+		rsp = append(rsp, WalletChainRsp{
+			Walletchains: datas[i],
+			Tokens:       tokens,
+		})
+	}
+
+	return rsp, nil
+}

+ 1 - 0
routers/router.go

@@ -946,6 +946,7 @@ func InitRouter() *gin.Engine {
 	walletR.Use()
 	{
 		walletR.Use(token.Auth()).GET("QueryWalletAddress", wallet.QueryWalletAddress)
+		walletR.Use(token.Auth()).GET("QueryWalletChains", wallet.QueryWalletChains)
 	}
 
 	return r