Browse Source

wip:新增菜单

wkyuer 2 months ago
parent
commit
3939d75db4
2 changed files with 34 additions and 2 deletions
  1. 32 0
      internal/service/ad.go
  2. 2 2
      internal/tags/init.go

+ 32 - 0
internal/service/ad.go

@@ -5,6 +5,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jybxseo/utility"
 	"log"
 	"runtime"
@@ -65,6 +66,24 @@ type (
 		TopMenuMap    map[int][]*TopMenuItem //顶部
 		BottomLinkMap map[int][]*TopMenuItem //底部
 	}
+
+	Menu struct {
+		Name   string `json:"name"`
+		Layout string `json:"layout"`
+		Href   string `json:"href,omitempty"`
+		Childs []struct {
+			Name   string `json:"name"`
+			Desc   string `json:"desc"`
+			Childs []struct {
+				Name   string `json:"name"`
+				Href   string `json:"href,omitempty"`
+				Childs []struct {
+					Name string `json:"name"`
+					Href string `json:"href,omitempty"`
+				} `json:"childs,omitempty"`
+			} `json:"childs"`
+		} `json:"childs"`
+	}
 )
 
 func Ad(s_code string, n int) []adInfo {
@@ -199,3 +218,16 @@ func BottomLink(flag int) (rData *SiteMenu) {
 		MenuList: cacheMenu.BottomLinkMap[flag],
 	}
 }
+
+func TopMenuNew() []*Menu {
+	var newMenus []*Menu
+	list, _ := utility.Mgo.Find("jy_topMenu_new", `{"i_status":1}`, `{"i_sort":1}`, nil, false, -1, -1)
+	if list == nil || len(*list) == 0 {
+		return newMenus
+	}
+	if err := gconv.Struct(list, &newMenus); err != nil {
+		log.Println("获取菜单异常", err.Error())
+		return nil
+	}
+	return newMenus
+}

+ 2 - 2
internal/tags/init.go

@@ -11,7 +11,7 @@ func init() {
 	g.View().BindFunc("Ad", service.Ad)
 	g.View().BindFunc("JyTopMenu", service.TopMenu)       // 0:剑鱼标讯官网 1:品牌网站 2:资讯
 	g.View().BindFunc("JyBottomLink", service.BottomLink) // 0:剑鱼标讯官网 1:品牌网站 2:资讯
-
+	g.View().BindFunc("TopMenuNew", service.TopMenuNew)   //查询Tab数据
 	// 读取配置文件
 	g.View().BindFunc("GetConfigArr", GetConfigArr)
 	g.View().BindFunc("GetConfigMap", GetConfigMap)
@@ -46,5 +46,5 @@ func init() {
 	g.View().BindFunc("GetClassBidding", GetClassBidding) // 获取行业标讯
 	g.View().BindFunc("GetSortLocation", GetSortLocation) // 获取行业标讯
 	g.View().BindFunc("GetAllLocation", GetAllLocation)   // 获取行业标讯
-	g.View().BindFunc("ParseNtoBr", ParseNtoBr) // /n转<br>
+	g.View().BindFunc("ParseNtoBr", ParseNtoBr)           // /n转<br>
 }