فهرست منبع

增加搜索用户的接口

zou.yingbin 3 سال پیش
والد
کامیت
27be5b4157
6فایلهای تغییر یافته به همراه247 افزوده شده و 34 حذف شده
  1. 16 0
      controllers/wrTrade2/qryWrTrade.go
  2. 81 15
      docs/docs.go
  3. 70 10
      docs/swagger.json
  4. 48 9
      docs/swagger.yaml
  5. 31 0
      models/wrTrade2.go
  6. 1 0
      routers/router.go

+ 16 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -760,3 +760,19 @@ func QueryWrReckonSpotGoodsTradeSum(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryWrSearchUser
+// @Summary 查询用户
+// @Produce json
+// @Security ApiKeyAuth
+// @param username query string true "用户名称(模糊匹配)"
+// @Success 200 {array} models.WrSearchUser
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryWrSearchUser [get]
+// @Tags 仓单贸易v2
+func QueryWrSearchUser(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrSearchUser{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 81 - 15
docs/docs.go

@@ -1,14 +1,13 @@
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
+// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
 // This file was generated by swaggo/swag
-
 package docs
 
 import (
 	"bytes"
 	"encoding/json"
 	"strings"
+	"text/template"
 
-	"github.com/alecthomas/template"
 	"github.com/swaggo/swag"
 )
 
@@ -16,7 +15,7 @@ var doc = `{
     "schemes": {{ marshal .Schemes }},
     "swagger": "2.0",
     "info": {
-        "description": "{{.Description}}",
+        "description": "{{escape .Description}}",
         "title": "{{.Title}}",
         "termsOfService": "http://www.muchinfo.cn",
         "contact": {},
@@ -13854,6 +13853,48 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryWrSearchUser": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询用户",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户名称(模糊匹配)",
+                        "name": "username",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrSearchUser"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrSpecialMatchOrder": {
             "get": {
                 "security": [
@@ -14339,9 +14380,7 @@ var doc = `{
                 "code": {
                     "type": "integer"
                 },
-                "data": {
-                    "type": "object"
-                },
+                "data": {},
                 "msg": {
                     "type": "string"
                 },
@@ -17421,31 +17460,31 @@ var doc = `{
                     "type": "number"
                 },
                 "diffArbitrageQty": {
-                    "description": "套利变动量",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffExposoureQty": {
-                    "description": "变动量(套保敞口)",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffFutuQty": {
-                    "description": "变动量(期货总量) 平安:保值净持仓量今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffHedgeQty": {
-                    "description": "套保变动量",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffQty": {
-                    "description": "变动量(总敞口) 平安:净敞口今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffSpotHedgeQty": {
-                    "description": "变动量(现货应套保总量) 平安:应套保量今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffSpotQty": {
-                    "description": "变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "enumdicname": {
@@ -37078,6 +37117,26 @@ var doc = `{
                 }
             }
         },
+        "models.WrSearchUser": {
+            "type": "object",
+            "required": [
+                "username"
+            ],
+            "properties": {
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "用户名称(已脱敏)",
+                    "type": "string"
+                },
+                "username2": {
+                    "description": "用户名称(未脱敏)",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrSiteColumnDetail": {
             "type": "object",
             "properties": {
@@ -40466,6 +40525,13 @@ func (s *s) ReadDoc() string {
 			a, _ := json.Marshal(v)
 			return string(a)
 		},
+		"escape": func(v interface{}) string {
+			// escape tabs
+			str := strings.Replace(v.(string), "\t", "\\t", -1)
+			// replace " with \", and if that results in \\", replace that with \\\"
+			str = strings.Replace(str, "\"", "\\\"", -1)
+			return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
+		},
 	}).Parse(doc)
 	if err != nil {
 		return doc
@@ -40480,5 +40546,5 @@ func (s *s) ReadDoc() string {
 }
 
 func init() {
-	swag.Register(swag.Name, &s{})
+	swag.Register("swagger", &s{})
 }

+ 70 - 10
docs/swagger.json

@@ -13838,6 +13838,48 @@
                 }
             }
         },
+        "/WrTrade2/QueryWrSearchUser": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询用户",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户名称(模糊匹配)",
+                        "name": "username",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrSearchUser"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrSpecialMatchOrder": {
             "get": {
                 "security": [
@@ -14323,9 +14365,7 @@
                 "code": {
                     "type": "integer"
                 },
-                "data": {
-                    "type": "object"
-                },
+                "data": {},
                 "msg": {
                     "type": "string"
                 },
@@ -17405,31 +17445,31 @@
                     "type": "number"
                 },
                 "diffArbitrageQty": {
-                    "description": "套利变动量",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffExposoureQty": {
-                    "description": "变动量(套保敞口)",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffFutuQty": {
-                    "description": "变动量(期货总量) 平安:保值净持仓量今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffHedgeQty": {
-                    "description": "套保变动量",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffQty": {
-                    "description": "变动量(总敞口) 平安:净敞口今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffSpotHedgeQty": {
-                    "description": "变动量(现货应套保总量) 平安:应套保量今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "diffSpotQty": {
-                    "description": "变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动",
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
                     "type": "number"
                 },
                 "enumdicname": {
@@ -37062,6 +37102,26 @@
                 }
             }
         },
+        "models.WrSearchUser": {
+            "type": "object",
+            "required": [
+                "username"
+            ],
+            "properties": {
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "用户名称(已脱敏)",
+                    "type": "string"
+                },
+                "username2": {
+                    "description": "用户名称(未脱敏)",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrSiteColumnDetail": {
             "type": "object",
             "properties": {

+ 48 - 9
docs/swagger.yaml

@@ -4,8 +4,7 @@ definitions:
     properties:
       code:
         type: integer
-      data:
-        type: object
+      data: {}
       msg:
         type: string
       page:
@@ -2296,25 +2295,25 @@ definitions:
         description: 套利量
         type: number
       diffArbitrageQty:
-        description: 套利变动
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交
         type: number
       diffExposoureQty:
-        description: 变动量(套保敞口)
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
         type: number
       diffFutuQty:
-        description: 变动量(期货总量) 平安:保值净持仓量今日变动
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
         type: number
       diffHedgeQty:
-        description: 套保变动
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交
         type: number
       diffQty:
-        description: 变动量(总敞口) 平安:净敞口今日变动
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
         type: number
       diffSpotHedgeQty:
-        description: 变动量(现货应套保总量) 平安:应套保量今日变动
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
         type: number
       diffSpotQty:
-        description: 变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
         type: number
       enumdicname:
         description: 单位名称
@@ -16962,6 +16961,20 @@ definitions:
         description: 更新时间
         type: string
     type: object
+  models.WrSearchUser:
+    properties:
+      userid:
+        description: 用户ID
+        type: integer
+      username:
+        description: 用户名称(已脱敏)
+        type: string
+      username2:
+        description: 用户名称(未脱敏)
+        type: string
+    required:
+    - username
+    type: object
   models.WrSiteColumnDetail:
     properties:
       brief:
@@ -28258,6 +28271,32 @@ paths:
       summary: 查询融资合同费用明细
       tags:
       - 仓单贸易v2
+  /WrTrade2/QueryWrSearchUser:
+    get:
+      parameters:
+      - description: 用户名称(模糊匹配)
+        in: query
+        name: username
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrSearchUser'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询用户
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryWrSpecialMatchOrder:
     get:
       description: 页面 现货仓单 | 预售仓单 -> 指定成交

+ 31 - 0
models/wrTrade2.go

@@ -4657,3 +4657,34 @@ func (r *WrReckonSpotGoodsTradeSum) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// WrSearchUser 搜索用户
+type WrSearchUser struct {
+	USERNAME  string `json:"username"  xorm:"'USERNAME'" form:"username" binding:"required"` // 用户名称(已脱敏)
+	USERID    int64  `json:"userid"  xorm:"'USERID'"`                                        // 用户ID
+	USERNAME2 string `json:"username2"  xorm:"'-'"`                                          // 用户名称(未脱敏)
+}
+
+func (r *WrSearchUser) calc() {
+	r.USERNAME2 = r.USERNAME
+	r.USERNAME = EncryptByStar(r.USERNAME)
+}
+
+func (r *WrSearchUser) buildSql() string {
+	var sqlId utils.SQLVal = `
+select t.userid, t.accountname username from useraccount t
+where t.accountname like '%%%v%%'
+`
+	sqlId.FormatParam(r.USERNAME)
+	return sqlId.String()
+}
+
+// GetDataEx 获取搜索用户
+func (r *WrSearchUser) GetDataEx() (interface{}, error) {
+	sData := make([]WrSearchUser, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -582,6 +582,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QuerySpotGroupTradeSumDetail", wrTrade2.QuerySpotGroupTradeSumDetail)
 		wrTrade2R.GET("QueryWrPreSaleInfo", wrTrade2.QueryWrPreSaleInfo)
 		wrTrade2R.GET("QueryWrReckonSpotGoodsTradeSum", wrTrade2.QueryWrReckonSpotGoodsTradeSum)
+		wrTrade2R.GET("QueryWrSearchUser", wrTrade2.QueryWrSearchUser)
 	}
 
 	// **************************天津麦顿*************************