|
@@ -9,11 +9,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"jy/src/jfw/config"
|
|
|
- "jy/src/jfw/jyutil"
|
|
|
- "jy/src/jfw/paging"
|
|
|
"log"
|
|
|
- "math"
|
|
|
- "math/rand"
|
|
|
"strconv"
|
|
|
"sync"
|
|
|
"time"
|
|
@@ -58,18 +54,10 @@ func RegionAndInformationAndTender() map[string]interface{} {
|
|
|
|
|
|
// HotSubjectMatter 热门标的物
|
|
|
func HotSubjectMatter() []map[string]interface{} {
|
|
|
- checkedLetter := LetterArr[getRandomWithAll(0, len(LetterArr))]
|
|
|
- industryHref := fmt.Sprintf("/tags/industry/%s_%s_all_%s.html", "%v", "all", "%v")
|
|
|
- letterLabel, _, _ := GetLetterPaging(1, checkedLetter) //热门标的物 随机字母标签
|
|
|
- tradeLabel := GetIndustry(industryHref) //热门标的物 行业分类标签
|
|
|
- letterLabel = append(letterLabel, tradeLabel...)
|
|
|
- var subjectMatter []map[string]interface{}
|
|
|
- if len(letterLabel) > 0 {
|
|
|
- for _, v := range jyutil.GenerateRandomNumber(0, len(letterLabel)-1, 200) {
|
|
|
- subjectMatter = append(subjectMatter, letterLabel[v])
|
|
|
- }
|
|
|
+ if config.HotSubjectMatter == nil || len(config.HotSubjectMatter) == 0 {
|
|
|
+ return config.GetLetterMap(qu.InterfaceToStr(config.Seoconfig["hotSubjectMatter"]))
|
|
|
}
|
|
|
- return subjectMatter
|
|
|
+ return config.HotSubjectMatter
|
|
|
}
|
|
|
|
|
|
// 最新更新的200中标企业
|
|
@@ -262,83 +250,6 @@ func RecommendationBeacon() []Signal {
|
|
|
return data
|
|
|
}
|
|
|
|
|
|
-// 不包含上限 [min, max)
|
|
|
-func getRandomWithAll(min, max int) int {
|
|
|
- rand.Seed(time.Now().UnixNano())
|
|
|
- return rand.Intn(max-min) + min
|
|
|
-}
|
|
|
-
|
|
|
-// this.T["letterList"],this.T["letterListCount"],this.T["pagingMap"]=this.GetLetterPaging(pageNum,checkedLetter)
|
|
|
-func GetLetterPaging(pageNum int, checkedLetter string) (letterList []map[string]interface{}, letterListCount int64, pagingMap map[string]interface{}) {
|
|
|
- seoLetterPageSize := qu.Int64All(config.Seoconfig["seoLetterPageSize"])
|
|
|
- if pageNum == 0 {
|
|
|
- pageNum = 1
|
|
|
- }
|
|
|
- letterList, letterListCount = GetLetterMap(seoLetterPageSize, int64(pageNum), checkedLetter)
|
|
|
- pagecount := int(math.Ceil(qu.Float64All(letterListCount) / float64(seoLetterPageSize)))
|
|
|
- paging := paging.PaggingHtml(pageNum, pagecount, fmt.Sprintf("/tags/letter/%s", checkedLetter)+"_%v.html")
|
|
|
-
|
|
|
- pagingMap = map[string]interface{}{
|
|
|
- "paging": paging,
|
|
|
- "pageNum": pageNum,
|
|
|
- "pageCount": pagecount,
|
|
|
- "pageSize": seoLetterPageSize,
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-func GetLetterMap(pageSize, pageNum int64, letter string) ([]map[string]interface{}, int64) {
|
|
|
- m := []map[string]interface{}{}
|
|
|
- sql := `select id,name,letter from seo_words.seo_resource where letter = ? and state=1 order by id desc`
|
|
|
- cql := `select count(1) from seo_words.seo_resource where letter = ? and state=1`
|
|
|
- offset := (pageNum - 1) * pageSize
|
|
|
- sql += fmt.Sprintf(" limit %v,%v", offset, pageSize)
|
|
|
- data := public.BaseMysql.SelectBySql(sql, letter)
|
|
|
- count := public.BaseMysql.CountBySql(cql, letter)
|
|
|
- if data != nil {
|
|
|
- for _, v := range *data {
|
|
|
- letter := qu.ObjToString(v["letter"])
|
|
|
- id := qu.Int64All(v["id"])
|
|
|
- name := qu.ObjToString(v["name"])
|
|
|
- name += qu.ObjToString(config.Seoconfig["seoKeywordSuffix"])
|
|
|
- m = append(m, map[string]interface{}{
|
|
|
- "name": name,
|
|
|
- "url": fmt.Sprintf("/tags/letter/all_all_all_%v_%v.html", letter, id),
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- return m, count
|
|
|
-}
|
|
|
-
|
|
|
-func GetIndustry(industryHref string) []map[string]interface{} {
|
|
|
- //data := public.BaseMysql.SelectBySql(`select a.id,a.name,b.id class_id,b.name class_1 from seo_words.seo_industry a left join seo_words.seo_industry_class b on a.class_1=b.name order by a.class_1`)
|
|
|
- data := public.BaseMysql.SelectBySql(`select a.id,a.name,b.id class_id,b.name class_1 from seo_words.seo_industry a inner join seo_words.seo_industry_class b on a.class_1=b.name and a.class_2 !='药品' order by a.class_1`)
|
|
|
- industryArr := []string{}
|
|
|
- industryMap := map[string][]map[string]interface{}{}
|
|
|
- if len(*data) > 0 && data != nil {
|
|
|
- for _, v := range *data {
|
|
|
- class := qu.ObjToString(v["class_1"])
|
|
|
- name := qu.ObjToString(v["name"])
|
|
|
- id := qu.Int64All(v["id"])
|
|
|
- industryId := qu.Int64All(v["class_id"])
|
|
|
- if !IsInArr(industryArr, class) {
|
|
|
- industryArr = append(industryArr, class)
|
|
|
- }
|
|
|
- industryMap[class] = append(industryMap[class], map[string]interface{}{
|
|
|
- "name": name + qu.ObjToString(config.Seoconfig["seoKeywordSuffix"]),
|
|
|
- // "url": fmt.Sprintf("/tags/industry/%v_all_all_%v.html", industryId, id),
|
|
|
- "url": fmt.Sprintf(industryHref, industryId, id),
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- m := []map[string]interface{}{}
|
|
|
- //
|
|
|
- for _, v := range industryArr {
|
|
|
- m = append(m, industryMap[v]...)
|
|
|
- }
|
|
|
- return m
|
|
|
-}
|
|
|
-
|
|
|
type BuyerList struct {
|
|
|
Name string `json:"name"`
|
|
|
Url string `json:"url"`
|
|
@@ -435,30 +346,6 @@ func GetIncludedInfo() map[string]interface{} {
|
|
|
return m
|
|
|
}
|
|
|
|
|
|
-func HotKey() []string {
|
|
|
- if bytes, err := redis.GetBytes(RedisNameNew, "jyhotkey_7"); err == nil && bytes != nil {
|
|
|
- rData := []string{}
|
|
|
- if err := json.Unmarshal(*bytes, &rData); err != nil {
|
|
|
- log.Printf("[MANAGER-ERR]jyhotkey_7 GetData Error %v \n", err)
|
|
|
- return nil
|
|
|
- }
|
|
|
- return rData
|
|
|
- }
|
|
|
- num := 7
|
|
|
- count := public.BaseMysql.CountBySql(`select count(1) from seo_words.seo_resource where state=1;`)
|
|
|
- rand.Seed(time.Now().UnixNano())
|
|
|
- randNum := rand.Intn(int(count) - num)
|
|
|
- data := public.BaseMysql.SelectBySql(`select name from seo_words.seo_resource where state=1 limit ?,?`, randNum, num)
|
|
|
- arr := []string{}
|
|
|
- for _, v := range *data {
|
|
|
- arr = append(arr, qu.ObjToString(v["name"]))
|
|
|
- }
|
|
|
- if bytes, err := json.Marshal(arr); err == nil && bytes != nil {
|
|
|
- _ = redis.PutBytes(RedisNameNew, "jyhotkey_7", &bytes, 10*60)
|
|
|
- }
|
|
|
- return arr
|
|
|
-}
|
|
|
-
|
|
|
func NewIndexbids(session *httpsession.Session, r *http.Request) []map[string]interface{} {
|
|
|
if bytes, err := redis.GetBytes(RedisNameNew, "jyNewIndexbids"); err == nil && bytes != nil {
|
|
|
rData := []map[string]interface{}{}
|