Browse Source

"查询交易端菜单"接口增加功能菜单

Simon Zhou 5 năm trước cách đây
mục cha
commit
c63b68e531
5 tập tin đã thay đổi với 343 bổ sung64 xóa
  1. 2 2
      config/config.xml
  2. 105 20
      controllers/common/table.go
  3. 86 14
      docs/docs.go
  4. 86 14
      docs/swagger.json
  5. 64 14
      docs/swagger.yaml

+ 2 - 2
config/config.xml

@@ -16,12 +16,12 @@
         <DbAddress value="192.168.31.117"/>
         <DbName    value="orcl"/>
         <DbPort    value="1521"/>
-        <DbUser    value="mtp2_test118"/>
+        <DbUser    value="mtp2_test104"/>
         <DbPwd     value="muchinfo"/>
     </DbSetting>
 
     <RedisSetting>
-        <Address   value="192.168.31.118"/>
+        <Address   value="192.168.31.104"/>
         <Port      value="5007"/>
         <Timeout   value="3"/>
         <ConnNum   value="1"/>

+ 105 - 20
controllers/common/table.go

@@ -20,25 +20,51 @@ type QueryTraderMenuReq struct {
 	LoginID int `form:"loginid" binding:"required"`
 }
 
+// QueryTraderMenuRsp 交易端菜单
+type QueryTraderMenuRsp struct {
+	QuoteMenu     []QuotePrimaryMenu     `json:"QuoteMenu"`     // 报价牌分类菜单
+	OperationMenu []OperationPrimaryMenu `json:"OperationMenu"` // 功能菜单
+}
+
 // QuotePrimaryMenu 报价牌一级分类菜单
 type QuotePrimaryMenu struct {
-	Index        int                  `json:"index"`      // 序号
-	Key          string               `json:"key"`        // 键名
-	Name         string               `json:"name"`       // 菜单名称
-	SubTitleType int                  `json:"titletype"`  // 子菜单标题模式:0-市场名称;1-外部交易所名称
-	TradeModes   string               `json:"trademodes"` // 包含市场交易类型
-	SubMenus     []QuoteSecondaryMenu `json:"submenus"`   // 子菜单
+	Index        int                  `json:"Index"`        // 序号
+	Key          string               `json:"Key"`          // 键名
+	Name         string               `json:"Name"`         // 菜单名称
+	SubTitleType int                  `json:"SubTitleType"` // 子菜单标题模式:0-市场名称;1-外部交易所名称
+	TradeModes   string               `json:"TradeModes"`   // 包含市场交易类型
+	SubMenus     []QuoteSecondaryMenu `json:"SubMenus"`     // 子菜单
 }
 
 // QuoteSecondaryMenu 报价牌二级分类菜单
 type QuoteSecondaryMenu struct {
-	Index          int    `json:"index"`                                  // 序号
-	MarketID       int    `json:"marketid"`                               // 市场ID
-	TradeMode      int    `json:"trademode"`                              // 交易模式
-	MenuTitle      string `json:"menutitle" xorm:"'ExExchangeName'"`      // 菜单标题(市场名称或外部交易所名称)
-	GoodsGroupIDs  []int  `json:"goodsgroupids"`                          // 商品组ID列表
-	ExExchangeID   int    `json:"exexchangeid" xorm:"'ExExchangeID'"`     // 外部交易所ID
-	ExExchangeCode string `json:"exexchangecode" xorm:"'ExExchangeCode'"` // 外部交易所代码
+	Index          int    `json:"Index"`                                  // 序号
+	MarketID       int    `json:"MarketID"`                               // 市场ID
+	TradeMode      int    `json:"TradeMode"`                              // 交易模式
+	MenuTitle      string `json:"MenuTitle" xorm:"'ExExchangeName'"`      // 菜单标题(市场名称或外部交易所名称)
+	GoodsGroupIDs  []int  `json:"GoodsGroupIDs"`                          // 商品组ID列表
+	ExExchangeID   int    `json:"ExExchangeID" xorm:"'ExExchangeID'"`     // 外部交易所ID
+	ExExchangeCode string `json:"ExExchangeCode" xorm:"'ExExchangeCode'"` // 外部交易所代码
+}
+
+// OperationPrimaryMenu 一级功能菜单
+type OperationPrimaryMenu struct {
+	Key      string                   `json:"Key"`      // 菜单KEY
+	Label    string                   `json:"Label"`    // 菜单标题
+	Children []OperationSecondaryMenu `json:"Children"` // 二级功能菜单
+}
+
+// OperationSecondaryMenu 二级功能菜单
+type OperationSecondaryMenu struct {
+	Key     string             `json:"Key"`     // 菜单KEY
+	Label   string             `json:"Label"`   // 菜单标题
+	TabList []OperationTabMenu `json:"TabList"` // 三级功能菜单
+}
+
+// OperationTabMenu 三级功能菜单
+type OperationTabMenu struct {
+	Key   string `json:"Key"`   // 菜单KEY
+	Label string `json:"Label"` // 菜单标题
 }
 
 // QueryTraderMenu 查询交易端菜单
@@ -46,7 +72,7 @@ type QuoteSecondaryMenu struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param loginid query int true "登录账号"
-// @Success 200 {object} QuotePrimaryMenu
+// @Success 200 {object} QueryTraderMenuRsp
 // @Failure 500 {object} app.Response
 // @Router /Common/QueryTraderMenu [get]
 // @Tags 通用
@@ -61,16 +87,23 @@ func QueryTraderMenu(c *gin.Context) {
 		return
 	}
 
-	datas, _ := getMenu(req.LoginID)
-	menuMap := make(map[string]interface{})
-	menuMap["menu"] = datas
+	var queryTraderMenuRsp QueryTraderMenuRsp
+	// 获取行情报价牌分类菜单
+	if datas, err := getQuoteMenu(req.LoginID); err == nil {
+		queryTraderMenuRsp.QuoteMenu = datas
+	}
+	// 获取功能菜单
+	if datas, err := getOperationMenu(); err == nil {
+		queryTraderMenuRsp.OperationMenu = datas
+	}
 
 	// 查询成功
-	logger.GetLogger().Infof("QueryPreasleApply successed: %v", menuMap)
-	appG.Response(http.StatusOK, e.SUCCESS, menuMap)
+	logger.GetLogger().Infof("QueryPreasleApply successed: %v", queryTraderMenuRsp)
+	appG.Response(http.StatusOK, e.SUCCESS, queryTraderMenuRsp)
 }
 
-func getMenu(loginID int) ([]QuotePrimaryMenu, error) {
+// getQuoteMenu 获取行情报价牌分类菜单
+func getQuoteMenu(loginID int) ([]QuotePrimaryMenu, error) {
 	engine := db.GetEngine()
 	rst := make([]QuotePrimaryMenu, 0)
 
@@ -178,3 +211,55 @@ func getMenu(loginID int) ([]QuotePrimaryMenu, error) {
 
 	return rst, nil
 }
+
+// getOperationMenu 获取功能菜单
+func getOperationMenu() ([]OperationPrimaryMenu, error) {
+	engine := db.GetEngine()
+	rst := make([]OperationPrimaryMenu, 0)
+
+	// 获取一级功能菜单
+	opm := make([]models.Tablecolumnconfig, 0)
+	if err := engine.Where("IsShow = 1 and TableKey = ?", "trader_operation_master_menu").Asc("ORDERINDEX").Find(&opm); err != nil {
+		return nil, err
+	}
+	for _, pv := range opm {
+		var operationPrimaryMenu = OperationPrimaryMenu{
+			Key:      pv.Columnfield,
+			Label:    pv.Columntitle,
+			Children: make([]OperationSecondaryMenu, 0),
+		}
+
+		// 获取二级功能菜单
+		osm := make([]models.Tablecolumnconfig, 0)
+		if err := engine.Where("IsShow = 1 and Remark = ?", operationPrimaryMenu.Key).Asc("ORDERINDEX").Find(&osm); err != nil {
+			return nil, err
+		}
+		for _, sv := range osm {
+			var operationSecondaryMenu = OperationSecondaryMenu{
+				Key:     sv.Columnfield,
+				Label:   sv.Columntitle,
+				TabList: make([]OperationTabMenu, 0),
+			}
+
+			// 获取三级功能菜单
+			otm := make([]models.Tablecolumnconfig, 0)
+			if err := engine.Where("IsShow = 1 and Remark = ?", operationSecondaryMenu.Key).Asc("ORDERINDEX").Find(&otm); err != nil {
+				return nil, err
+			}
+			for _, tv := range otm {
+				var operationTabMenu = OperationTabMenu{
+					Key:   tv.Columnfield,
+					Label: tv.Columntitle,
+				}
+
+				operationSecondaryMenu.TabList = append(operationSecondaryMenu.TabList, operationTabMenu)
+			}
+
+			operationPrimaryMenu.Children = append(operationPrimaryMenu.Children, operationSecondaryMenu)
+		}
+
+		rst = append(rst, operationPrimaryMenu)
+	}
+
+	return rst, nil
+}

+ 86 - 14
docs/docs.go

@@ -396,7 +396,7 @@ var doc = `{
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/common.QuotePrimaryMenu"
+                            "$ref": "#/definitions/common.QueryTraderMenuRsp"
                         }
                     },
                     "500": {
@@ -667,33 +667,105 @@ var doc = `{
                 }
             }
         },
+        "common.OperationPrimaryMenu": {
+            "type": "object",
+            "properties": {
+                "Children": {
+                    "description": "二级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.OperationSecondaryMenu"
+                    }
+                },
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "common.OperationSecondaryMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                },
+                "TabList": {
+                    "description": "三级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.OperationTabMenu"
+                    }
+                }
+            }
+        },
+        "common.OperationTabMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "common.QueryTraderMenuRsp": {
+            "type": "object",
+            "properties": {
+                "OperationMenu": {
+                    "description": "功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.OperationPrimaryMenu"
+                    }
+                },
+                "QuoteMenu": {
+                    "description": "报价牌分类菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.QuotePrimaryMenu"
+                    }
+                }
+            }
+        },
         "common.QuotePrimaryMenu": {
             "type": "object",
             "properties": {
-                "index": {
+                "Index": {
                     "description": "序号",
                     "type": "integer"
                 },
-                "key": {
+                "Key": {
                     "description": "键名",
                     "type": "string"
                 },
-                "name": {
+                "Name": {
                     "description": "菜单名称",
                     "type": "string"
                 },
-                "submenus": {
+                "SubMenus": {
                     "description": "子菜单",
                     "type": "array",
                     "items": {
                         "$ref": "#/definitions/common.QuoteSecondaryMenu"
                     }
                 },
-                "titletype": {
+                "SubTitleType": {
                     "description": "子菜单标题模式:0-市场名称;1-外部交易所名称",
                     "type": "integer"
                 },
-                "trademodes": {
+                "TradeModes": {
                     "description": "包含市场交易类型",
                     "type": "string"
                 }
@@ -702,34 +774,34 @@ var doc = `{
         "common.QuoteSecondaryMenu": {
             "type": "object",
             "properties": {
-                "exexchangecode": {
+                "ExExchangeCode": {
                     "description": "外部交易所代码",
                     "type": "string"
                 },
-                "exexchangeid": {
+                "ExExchangeID": {
                     "description": "外部交易所ID",
                     "type": "integer"
                 },
-                "goodsgroupids": {
+                "GoodsGroupIDs": {
                     "description": "商品组ID列表",
                     "type": "array",
                     "items": {
                         "type": "integer"
                     }
                 },
-                "index": {
+                "Index": {
                     "description": "序号",
                     "type": "integer"
                 },
-                "marketid": {
+                "MarketID": {
                     "description": "市场ID",
                     "type": "integer"
                 },
-                "menutitle": {
+                "MenuTitle": {
                     "description": "菜单标题(市场名称或外部交易所名称)",
                     "type": "string"
                 },
-                "trademode": {
+                "TradeMode": {
                     "description": "交易模式",
                     "type": "integer"
                 }

+ 86 - 14
docs/swagger.json

@@ -380,7 +380,7 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/common.QuotePrimaryMenu"
+                            "$ref": "#/definitions/common.QueryTraderMenuRsp"
                         }
                     },
                     "500": {
@@ -651,33 +651,105 @@
                 }
             }
         },
+        "common.OperationPrimaryMenu": {
+            "type": "object",
+            "properties": {
+                "Children": {
+                    "description": "二级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.OperationSecondaryMenu"
+                    }
+                },
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "common.OperationSecondaryMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                },
+                "TabList": {
+                    "description": "三级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.OperationTabMenu"
+                    }
+                }
+            }
+        },
+        "common.OperationTabMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "common.QueryTraderMenuRsp": {
+            "type": "object",
+            "properties": {
+                "OperationMenu": {
+                    "description": "功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.OperationPrimaryMenu"
+                    }
+                },
+                "QuoteMenu": {
+                    "description": "报价牌分类菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/common.QuotePrimaryMenu"
+                    }
+                }
+            }
+        },
         "common.QuotePrimaryMenu": {
             "type": "object",
             "properties": {
-                "index": {
+                "Index": {
                     "description": "序号",
                     "type": "integer"
                 },
-                "key": {
+                "Key": {
                     "description": "键名",
                     "type": "string"
                 },
-                "name": {
+                "Name": {
                     "description": "菜单名称",
                     "type": "string"
                 },
-                "submenus": {
+                "SubMenus": {
                     "description": "子菜单",
                     "type": "array",
                     "items": {
                         "$ref": "#/definitions/common.QuoteSecondaryMenu"
                     }
                 },
-                "titletype": {
+                "SubTitleType": {
                     "description": "子菜单标题模式:0-市场名称;1-外部交易所名称",
                     "type": "integer"
                 },
-                "trademodes": {
+                "TradeModes": {
                     "description": "包含市场交易类型",
                     "type": "string"
                 }
@@ -686,34 +758,34 @@
         "common.QuoteSecondaryMenu": {
             "type": "object",
             "properties": {
-                "exexchangecode": {
+                "ExExchangeCode": {
                     "description": "外部交易所代码",
                     "type": "string"
                 },
-                "exexchangeid": {
+                "ExExchangeID": {
                     "description": "外部交易所ID",
                     "type": "integer"
                 },
-                "goodsgroupids": {
+                "GoodsGroupIDs": {
                     "description": "商品组ID列表",
                     "type": "array",
                     "items": {
                         "type": "integer"
                     }
                 },
-                "index": {
+                "Index": {
                     "description": "序号",
                     "type": "integer"
                 },
-                "marketid": {
+                "MarketID": {
                     "description": "市场ID",
                     "type": "integer"
                 },
-                "menutitle": {
+                "MenuTitle": {
                     "description": "菜单标题(市场名称或外部交易所名称)",
                     "type": "string"
                 },
-                "trademode": {
+                "TradeMode": {
                     "description": "交易模式",
                     "type": "integer"
                 }

+ 64 - 14
docs/swagger.yaml

@@ -9,52 +9,102 @@ definitions:
       msg:
         type: string
     type: object
+  common.OperationPrimaryMenu:
+    properties:
+      Children:
+        description: 二级功能菜单
+        items:
+          $ref: '#/definitions/common.OperationSecondaryMenu'
+        type: array
+      Key:
+        description: 菜单KEY
+        type: string
+      Label:
+        description: 菜单标题
+        type: string
+    type: object
+  common.OperationSecondaryMenu:
+    properties:
+      Key:
+        description: 菜单KEY
+        type: string
+      Label:
+        description: 菜单标题
+        type: string
+      TabList:
+        description: 三级功能菜单
+        items:
+          $ref: '#/definitions/common.OperationTabMenu'
+        type: array
+    type: object
+  common.OperationTabMenu:
+    properties:
+      Key:
+        description: 菜单KEY
+        type: string
+      Label:
+        description: 菜单标题
+        type: string
+    type: object
+  common.QueryTraderMenuRsp:
+    properties:
+      OperationMenu:
+        description: 功能菜单
+        items:
+          $ref: '#/definitions/common.OperationPrimaryMenu'
+        type: array
+      QuoteMenu:
+        description: 报价牌分类菜单
+        items:
+          $ref: '#/definitions/common.QuotePrimaryMenu'
+        type: array
+    type: object
   common.QuotePrimaryMenu:
     properties:
-      index:
+      Index:
         description: 序号
         type: integer
-      key:
+      Key:
         description: 键名
         type: string
-      name:
+      Name:
         description: 菜单名称
         type: string
-      submenus:
+      SubMenus:
         description: 子菜单
         items:
           $ref: '#/definitions/common.QuoteSecondaryMenu'
         type: array
-      titletype:
+      SubTitleType:
         description: 子菜单标题模式:0-市场名称;1-外部交易所名称
         type: integer
-      trademodes:
+      TradeModes:
         description: 包含市场交易类型
         type: string
     type: object
   common.QuoteSecondaryMenu:
     properties:
-      exexchangecode:
+      ExExchangeCode:
         description: 外部交易所代码
         type: string
-      exexchangeid:
+      ExExchangeID:
         description: 外部交易所ID
         type: integer
-      goodsgroupids:
+      GoodsGroupIDs:
         description: 商品组ID列表
         items:
           type: integer
         type: array
-      index:
+      Index:
         description: 序号
         type: integer
-      marketid:
+      MarketID:
         description: 市场ID
         type: integer
-      menutitle:
+      MenuTitle:
         description: 菜单标题(市场名称或外部交易所名称)
         type: string
-      trademode:
+      TradeMode:
         description: 交易模式
         type: integer
     type: object
@@ -1365,7 +1415,7 @@ paths:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/common.QuotePrimaryMenu'
+            $ref: '#/definitions/common.QueryTraderMenuRsp'
         "500":
           description: Internal Server Error
           schema: