Explorar el Código

feat:首页热门采购单位

wangshan hace 2 años
padre
commit
bebb8a928f

+ 29 - 0
src/jfw/front/classificationTag.go

@@ -3,6 +3,7 @@ package front
 import (
 	qu "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
 	"app.yhyue.com/moapp/jypkg/public"
@@ -265,3 +266,31 @@ func GetIndustry(industryHref string) []map[string]interface{} {
 	}
 	return m
 }
+
+type BuyerList struct {
+	Name string `json:"name"`
+	Id   string `json:"id"`
+}
+
+// 热门采购单位
+func HotBuyerList() []*BuyerList {
+	//获取随机数
+	// 使用当前时间作为随机数生成器的种子
+	rand.Seed(time.Now().UnixNano())
+	// 获取一个范围在 [0, 100) 的随机整数
+	start := rand.Intn(100)
+	buyerQuery := fmt.Sprintf(`{"query": {"bool": {"must": [{"exists": {"field": "name"}}]}},"from": %d,"size": %d}`, start, 200)
+	log.Println("buyerQuery:", buyerQuery)
+	data := elastic.Get("buyer", "buyer", buyerQuery)
+	if len(*data) > 0 {
+		var buyerList []*BuyerList
+		for _, b := range *data {
+			buyerList = append(buyerList, &BuyerList{
+				Name: qu.ObjToString(b["name"]),
+				Id:   encrypt.EncodeArticleId2ByCheck(qu.ObjToString(b["_id"])),
+			})
+		}
+		return buyerList
+	}
+	return nil
+}

+ 2 - 0
src/jfw/front/pcIndex.go

@@ -107,6 +107,8 @@ func (m *PcIndex) NewSordfish(flag string) error {
 			m.T["recommend"] = ContentRecommendation()
 			//推荐标讯专区
 			m.T["recommendBeacon"] = RecommendationBeacon()
+			//热门采购单位
+			m.T["hotBuyers"] = HotBuyerList()
 			m.T["hasLogin"] = m.GetSession("userId") != ""
 			return m.Render("/pc/index.html", &m.T)
 		}

+ 5 - 1
src/web/templates/pc/index.html

@@ -240,7 +240,11 @@
                 {{end}}
               </ul>
             </div>
-            <div class="hot-buyer-content line-show"></div>
+            <div class="hot-buyer-content simple-show">
+                {{range $k,$v := .T.hotBuyers}}
+                  <a class="tab-link tab-label" href="/swordfish/page_big_pc/unit_portrayal/{{$v.Name}}" target="_blank">{{$v.Name}}</a>
+                {{end}}
+            </div>
           </div>
         </div>
       </div>