Prechádzať zdrojové kódy

增加 /Wallet/QueryWalletTokens 代币信息查询接口

muchinfo 3 týždňov pred
rodič
commit
a0f2ef0167

+ 1 - 1
controllers/tradexx/qryTradexx.go

@@ -22,7 +22,7 @@ import (
 // @Param    trademodes      query    string false "交易模式, 格式 1,2,3"
 // @Param    marketids       query    string false "市场id, 格式 1,2,3"
 // @Param    goodsid         query    int    false "商品id"
-// @Param    tradeid                         query string false "成交单号"
+// @Param    tradeid         query    string false "成交单号"
 // @Param    buyorsell       query    int    false "买卖方向 0-买 1-卖"
 // @Param    riskcontrolmode query    int    false "风控方式(52模式) 1:按单风控 2:按账户风控"
 // @Success  200             {array}  models.TradeHolderDetail

+ 32 - 1
controllers/wallet/chain.go

@@ -20,7 +20,7 @@ type QueryWalletChainsReq struct {
 // @Security ApiKeyAuth
 // @Param    channelCode query    string true "渠道代码"
 // @Success  200         {array}  models.WalletChainRsp
-// @Failure  500         {object} app.Response
+// @Failure  500      {object} app.Response
 // @Router   /Wallet/QueryWalletChains [get]
 // @Tags     钱包
 func QueryWalletChains(c *gin.Context) {
@@ -40,3 +40,34 @@ func QueryWalletChains(c *gin.Context) {
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 	}
 }
+
+type QueryWalletTokensReq struct {
+	Curreny string `form:"currency" binding:"required"` // 币种代码
+}
+
+// QueryWalletTokens
+// @Summary  查询代币信息
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param    currency query    string true "币种代码"
+// @Success  200      {array}  models.Wallettokens
+// @Failure  500         {object} app.Response
+// @Router   /Wallet/QueryWalletTokens [get]
+// @Tags     钱包
+func QueryWalletTokens(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryWalletTokensReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryWalletTokens failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	if rsp, err := models.GetWalletTokens(req.Curreny); err == nil {
+		appG.Response(http.StatusOK, e.SUCCESS, rsp)
+	} else {
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 42 - 0
docs/docs.go

@@ -21382,6 +21382,48 @@ const docTemplate = `{
                 }
             }
         },
+        "/Wallet/QueryWalletTokens": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "钱包"
+                ],
+                "summary": "查询代币信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "币种代码",
+                        "name": "currency",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Wallettokens"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/InsertXhcpSellBackApply": {
             "post": {
                 "security": [

+ 42 - 0
docs/swagger.json

@@ -21373,6 +21373,48 @@
                 }
             }
         },
+        "/Wallet/QueryWalletTokens": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "钱包"
+                ],
+                "summary": "查询代币信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "币种代码",
+                        "name": "currency",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Wallettokens"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/InsertXhcpSellBackApply": {
             "post": {
                 "security": [

+ 26 - 0
docs/swagger.yaml

@@ -46401,6 +46401,32 @@ paths:
       summary: 查询钱包链
       tags:
       - 钱包
+  /Wallet/QueryWalletTokens:
+    get:
+      parameters:
+      - description: 币种代码
+        in: query
+        name: currency
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Wallettokens'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询代币信息
+      tags:
+      - 钱包
   /WrTrade2/InsertXhcpSellBackApply:
     post:
       parameters:

+ 6 - 0
models/wallet.go

@@ -82,3 +82,9 @@ func GetWalletChains(channelCode string) ([]WalletChainRsp, error) {
 
 	return rsp, nil
 }
+
+func GetWalletTokens(currency string) ([]Wallettokens, error) {
+	rsp := make([]Wallettokens, 0)
+	err := db.GetEngine().Where("SYMBOL = ?", currency).Find(&rsp)
+	return rsp, err
+}

+ 1 - 0
routers/router.go

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