|
|
@@ -32,12 +32,13 @@ type QuotePrimaryMenu struct {
|
|
|
|
|
|
// QuoteSecondaryMenu 报价牌二级分类菜单
|
|
|
type QuoteSecondaryMenu struct {
|
|
|
- Index int `json:"index"` // 序号
|
|
|
- MarketID int `json:"marketid"` // 市场ID
|
|
|
- TradeMode int `json:"trademode"` // 交易模式
|
|
|
- MenuTitle string `json:"menutitle"` // 菜单标题(市场名称或外部交易所名称)
|
|
|
- GoodsGroupID int `json:"goodsgroupid"` // 商品组ID
|
|
|
- ExExchangeCode string `json:"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'"` // 外部交易所代码
|
|
|
}
|
|
|
|
|
|
// QueryTraderMenu 查询交易端菜单
|
|
|
@@ -45,7 +46,7 @@ type QuoteSecondaryMenu struct {
|
|
|
// @Produce json
|
|
|
// @Security ApiKeyAuth
|
|
|
// @Param loginid query int true "登录账号"
|
|
|
-// @Success 200 {object} app.Response
|
|
|
+// @Success 200 {object} QuotePrimaryMenu
|
|
|
// @Failure 500 {object} app.Response
|
|
|
// @Router /Common/QueryTraderMenu [get]
|
|
|
// @Tags 通用
|
|
|
@@ -120,13 +121,13 @@ func getMenu(loginID int) ([]QuotePrimaryMenu, error) {
|
|
|
quotePrimaryMenu.TradeModes = v.Remark
|
|
|
|
|
|
// 构建二级子菜单对象
|
|
|
- // 获取目标交易模式的市场信息
|
|
|
- markets := make([]models.Market, 0)
|
|
|
marketIDsStr := utils.JoinItoString(marketIDs, ",")
|
|
|
- if err := engine.Where(fmt.Sprintf(`TradeMode in (%s) and MarketID in (%s)`, quotePrimaryMenu.TradeModes, marketIDsStr)).Find(&markets); err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
if quotePrimaryMenu.SubTitleType == 0 {
|
|
|
+ // 获取目标交易模式的市场信息
|
|
|
+ markets := make([]models.Market, 0)
|
|
|
+ if err := engine.Where(fmt.Sprintf(`TradeMode in (%s) and MarketID in (%s)`, quotePrimaryMenu.TradeModes, marketIDsStr)).Find(&markets); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
// 使用市场名称
|
|
|
for mi, mv := range markets {
|
|
|
quoteSecondaryMenu := QuoteSecondaryMenu{
|
|
|
@@ -139,6 +140,37 @@ func getMenu(loginID int) ([]QuotePrimaryMenu, error) {
|
|
|
}
|
|
|
} else {
|
|
|
// 使用外部交易所名称
|
|
|
+ quoteSecondaryMenus := make([]QuoteSecondaryMenu, 0)
|
|
|
+ sql := fmt.Sprintf(`select distinct
|
|
|
+ e.autoid ExExchangeID,
|
|
|
+ e.ExExchangeName,
|
|
|
+ e.ExExchangeCode
|
|
|
+ from ExternalExchange e
|
|
|
+ inner join goodsgroup g on g.exexchangeid = e.autoid
|
|
|
+ inner join Market m on g.marketid = m.marketid
|
|
|
+ where m.trademode in (%s) and m.marketid in (%s)`, quotePrimaryMenu.TradeModes, marketIDsStr)
|
|
|
+ if err := engine.SQL(sql).Find("eSecondaryMenus); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 获取外部交易所对应的商品组信息
|
|
|
+ for ei, ev := range quoteSecondaryMenus {
|
|
|
+ q := "eSecondaryMenus[ei]
|
|
|
+ q.Index = ei
|
|
|
+ // 商品组列表
|
|
|
+ goodsgroups := make([]models.Goodsgroup, 0)
|
|
|
+ if err := engine.Where("Exexchangeid = ?", ev.ExExchangeID).Find(&goodsgroups); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ marketID := 0
|
|
|
+ var goodsGroupIDs []int
|
|
|
+ for _, gv := range goodsgroups {
|
|
|
+ marketID = int(gv.Marketid)
|
|
|
+ goodsGroupIDs = append(goodsGroupIDs, int(gv.Goodsgroupid))
|
|
|
+ }
|
|
|
+ q.MarketID = marketID
|
|
|
+ q.GoodsGroupIDs = goodsGroupIDs
|
|
|
+ }
|
|
|
+ quotePrimaryMenu.SubMenus = quoteSecondaryMenus
|
|
|
}
|
|
|
|
|
|
rst = append(rst, quotePrimaryMenu)
|