|
@@ -4,6 +4,7 @@ import (
|
|
|
util "app.yhyue.com/moapp/jybase/common"
|
|
|
. "app.yhyue.com/moapp/jybase/date"
|
|
|
mgo "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
"bytes"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
@@ -25,6 +26,7 @@ var (
|
|
|
|
|
|
type Navigation struct {
|
|
|
Name string
|
|
|
+ Code string
|
|
|
Href string
|
|
|
Pid string
|
|
|
}
|
|
@@ -70,6 +72,7 @@ func init() {
|
|
|
continue
|
|
|
}
|
|
|
data.Href = href
|
|
|
+ data.Code = code
|
|
|
data.Name = util.InterfaceToStr(v["s_columnname"])
|
|
|
data.Pid = pid
|
|
|
ColumnRelationship[code] = data
|
|
@@ -79,6 +82,10 @@ func init() {
|
|
|
|
|
|
// Course 剑鱼课堂首页课程 & 帮助中心热门视频 classify:0:中标比听课视频 1:帮助中心视频(获取所有)
|
|
|
func Course(num, iType int) *[]map[string]interface{} {
|
|
|
+ if data := redis.Get("other", fmt.Sprintf("course_%d_%d", num, iType)); data != nil {
|
|
|
+ dataMap, _ := data.([]map[string]interface{})
|
|
|
+ return &dataMap
|
|
|
+ }
|
|
|
//热门课程
|
|
|
/*var HotCourse *[]map[string]interface{}
|
|
|
hotQuery := map[string]interface{}{"i_type": 3, "i_status": 1, "l_endtime": map[string]interface{}{"$gt": time.Now().Unix()}, "l_publishtime": map[string]interface{}{"$lt": time.Now().Unix()}}
|
|
@@ -134,11 +141,17 @@ func Course(num, iType int) *[]map[string]interface{} {
|
|
|
}
|
|
|
}*/
|
|
|
//IdFormat(LatestCourses)
|
|
|
+ redis.Put("other", fmt.Sprintf("course_%d_%d", num, iType), *LatestCourses, 60*5)
|
|
|
+
|
|
|
return LatestCourses
|
|
|
}
|
|
|
|
|
|
// Library 文库
|
|
|
func Library(num int) (map[string]interface{}, error) {
|
|
|
+ if data := redis.Get("other", fmt.Sprintf("library_%d", num)); data != nil {
|
|
|
+ dataMap, _ := data.(map[string]interface{})
|
|
|
+ return dataMap, nil
|
|
|
+ }
|
|
|
b, _ := json.Marshal(map[string]interface{}{
|
|
|
"sign": "new",
|
|
|
"num": num,
|
|
@@ -165,6 +178,7 @@ func Library(num int) (map[string]interface{}, error) {
|
|
|
v["docFileSize"] = FormatSize(util.Float64All(v["docFileSize"]), "B")
|
|
|
}
|
|
|
m["data"] = data
|
|
|
+ redis.Put("other", fmt.Sprintf("library_%d", num), m, 5*60)
|
|
|
return m, nil
|
|
|
}
|
|
|
|
|
@@ -199,6 +213,10 @@ func FormatSize(size float64, unit string) string {
|
|
|
|
|
|
// GuidelineAndInformation t:一级栏目 s二级栏目 (首页剑鱼攻略与行业资讯首页公用)
|
|
|
func GuidelineAndInformation(t, s string, num int) *[]map[string]interface{} {
|
|
|
+ if data := redis.Get("other", fmt.Sprintf("guideline_information_%d_%s_%s", num, t, s)); data != nil {
|
|
|
+ dataMap, _ := data.([]map[string]interface{})
|
|
|
+ return &dataMap
|
|
|
+ }
|
|
|
query := map[string]interface{}{"s_contenttype": t, "s_secondclassifytype": s, "i_status": 1, "releasetime": map[string]interface{}{"$lt": time.Now().Unix()}}
|
|
|
data, _ := mongodb.Find("content", query, `{"releasetime":-1,"l_createdate":-1}`, `{"_id":1,"i_viewnum":1,s_title":1,"s_pic1":1,"s_pic":1,"releasetime":1,"s_description":1,"l_createdate":1,"s_contenttype":1,"s_secondclassifytype":1}`, false, 0, num)
|
|
|
if data != nil {
|
|
@@ -216,7 +234,7 @@ func GuidelineAndInformation(t, s string, num int) *[]map[string]interface{} {
|
|
|
v["s_pic1"] = SPic(util.InterfaceToStr(v["s_pic1"]))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ redis.Put("other", fmt.Sprintf("guideline_information_%d_%s_%s", num, t, s), *data, 5*60)
|
|
|
//IdFormat(data)
|
|
|
return data
|
|
|
}
|
|
@@ -381,15 +399,13 @@ func GuidelineDetails(id string, keyWord ...string) []map[string]interface{} {
|
|
|
}
|
|
|
|
|
|
//相关内容推荐
|
|
|
- recommendQuery := map[string]interface{}{
|
|
|
+ query = map[string]interface{}{
|
|
|
"_id": map[string]interface{}{
|
|
|
"$ne": []primitive.ObjectID{_id},
|
|
|
},
|
|
|
- "i_status": 1,
|
|
|
- "releasetime": map[string]interface{}{"$lt": time.Now().Unix()},
|
|
|
}
|
|
|
var recommend []map[string]interface{}
|
|
|
- dataRe, ok := mongodb.Find("content", recommendQuery, `{"releasetime":-1,"l_createdate":-1}`, `{"_id":1,"i_viewnum":1,"s_title":1,"s_pic1":1,"s_pic":1,"releasetime":1,"s_description":1,"l_createdate":1,"s_contenttype":1,"s_secondclassifytype":1}`, false, 0, 500)
|
|
|
+ dataRe, ok := mongodb.Find("content", query, `{"releasetime":-1,"l_createdate":-1}`, `{"_id":1,"i_viewnum":1,"s_title":1,"s_pic1":1,"s_pic":1,"releasetime":1,"s_description":1,"l_createdate":1,"s_contenttype":1,"s_secondclassifytype":1}`, false, 0, 500)
|
|
|
if ok && dataRe != nil && len(*dataRe) > 0 {
|
|
|
if len(*dataRe) > 3 {
|
|
|
for _, key := range GenerateRandomNumber(0, len(*dataRe), 3) {
|