|
@@ -0,0 +1,155 @@
|
|
|
+package front
|
|
|
+
|
|
|
+import (
|
|
|
+ qu "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jypkg/public"
|
|
|
+ "fmt"
|
|
|
+ "jy/src/jfw/config"
|
|
|
+ "jy/src/jfw/jyutil"
|
|
|
+ "jy/src/jfw/paging"
|
|
|
+ "math"
|
|
|
+ "math/rand"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type KeyType struct {
|
|
|
+ Name string
|
|
|
+ Url string
|
|
|
+}
|
|
|
+
|
|
|
+// RegionAndInformationAndTender 1地域 2信息类型 3热门招标
|
|
|
+func RegionAndInformationAndTender() map[string]interface{} {
|
|
|
+ data := make(map[string]interface{})
|
|
|
+ for _, v := range []int{1, 2, 3} {
|
|
|
+ data[fmt.Sprintf("labUrl_%d", v)] = GetLabUrl(v) //1地域 2信息类型 3热门招标
|
|
|
+ }
|
|
|
+ return data
|
|
|
+}
|
|
|
+
|
|
|
+// 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])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return subjectMatter
|
|
|
+}
|
|
|
+
|
|
|
+// ContentRecommendation 实用内容推荐
|
|
|
+func ContentRecommendation() map[KeyType][]KeyType {
|
|
|
+ columnCode, _ := config.Sysconfig["columnCode"].(map[string]interface{})
|
|
|
+ jySchoolCode := qu.InterfaceToStr(columnCode["招投标攻略"])
|
|
|
+ industryInfoCode := qu.InterfaceToStr(columnCode["行业资讯"])
|
|
|
+ industryInfoUrl, _ := config.Sysconfig["industryInfoUrl"].(map[string]interface{})
|
|
|
+ jySchoolUrl, _ := config.Sysconfig["jySchoolUrl"].(map[string]interface{})
|
|
|
+ column, ok := mongodb.Find("column", map[string]interface{}{"$or": []map[string]interface{}{
|
|
|
+ {"pid": "ztbgl"}, {"pid": "hyzx"}, {"pid": "bzzx"},
|
|
|
+ }}, "", "", false, -1, -1)
|
|
|
+ data := make(map[KeyType][]KeyType)
|
|
|
+ if ok && column != nil && len(*column) > 0 {
|
|
|
+ for _, v := range *column {
|
|
|
+ pid := qu.InterfaceToStr(v["pid"])
|
|
|
+ code := qu.InterfaceToStr(v["s_columncode"])
|
|
|
+ var v1, v2 KeyType
|
|
|
+ v1.Name = qu.InterfaceToStr(v["s_columnname"])
|
|
|
+ if pid == jySchoolCode {
|
|
|
+ v2.Name = "招投标攻略"
|
|
|
+ v2.Url = qu.InterfaceToStr(jySchoolUrl["homeUrl"])
|
|
|
+ v1.Url = fmt.Sprintf(qu.InterfaceToStr(jySchoolUrl["towUrl"]), code)
|
|
|
+ } else if pid == industryInfoCode {
|
|
|
+ v2.Name = "行业资讯"
|
|
|
+ v2.Url = qu.InterfaceToStr(industryInfoUrl["homeUrl"])
|
|
|
+ v1.Url = fmt.Sprintf(qu.InterfaceToStr(industryInfoUrl["towUrl"]), code)
|
|
|
+ } else if pid == industryInfoCode {
|
|
|
+ v2.Name = "帮助中心"
|
|
|
+ v2.Url = "/helpCenter/index"
|
|
|
+ v1.Url = fmt.Sprintf("/helpCenter/catalog/%s", code)
|
|
|
+ }
|
|
|
+ data[v2] = append(data[v2], v1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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 = ? order by id desc`
|
|
|
+ cql := `select count(1) from seo_words.seo_resource where letter = ?`
|
|
|
+ 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`)
|
|
|
+ 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
|
|
|
+}
|