|
@@ -96,14 +96,14 @@ func Library(num int) (map[string]interface{}, error) {
|
|
return m, err
|
|
return m, err
|
|
}
|
|
}
|
|
|
|
|
|
-// BiddingStrategy 招标攻略t:一级栏目 二级栏目类型取多少length (首页剑鱼攻略与攻略首页公用)
|
|
|
|
-func BiddingStrategy(t, num int) map[string][]map[string]interface{} {
|
|
|
|
|
|
+// GuidelineAndInformation t:一级栏目 二级栏目类型取多少length (首页剑鱼攻略与行业资讯首页公用)
|
|
|
|
+func GuidelineAndInformation(t string, num int) map[string][]map[string]interface{} {
|
|
res := make(map[string][]map[string]interface{})
|
|
res := make(map[string][]map[string]interface{})
|
|
- query := map[string]interface{}{"type": t}
|
|
|
|
- data := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, `{"id":1,"name":1,"title":1,"text":1,"l_publishtime":1}`, false, 0, 8)
|
|
|
|
|
|
+ query := map[string]interface{}{"s_contenttype": t}
|
|
|
|
+ data := mongodb.Find("content", query, `{"l_publishtime":-1}`, `{"id":1,"name":1,"title":1,"text":1,"l_publishtime":1}`, false, 0, 8)
|
|
if data != nil && len(*data) > 0 {
|
|
if data != nil && len(*data) > 0 {
|
|
for _, v := range *data {
|
|
for _, v := range *data {
|
|
- name := util.InterfaceToStr(v["name"])
|
|
|
|
|
|
+ name := util.InterfaceToStr(v["s_secondclassifytype"])
|
|
if len(res[name]) < num {
|
|
if len(res[name]) < num {
|
|
res[name] = append(res[name], v)
|
|
res[name] = append(res[name], v)
|
|
}
|
|
}
|
|
@@ -115,16 +115,16 @@ func BiddingStrategy(t, num int) map[string][]map[string]interface{} {
|
|
return res
|
|
return res
|
|
}
|
|
}
|
|
|
|
|
|
-// StrategyColumn 招标攻略栏目页 t一级栏目 n 二级栏目 Page 页码 size 数量
|
|
|
|
-func StrategyColumn(t, n, page, size int) (*[]map[string]interface{}, int, int, bool) {
|
|
|
|
|
|
+// ColumnHome 招标攻略与行业咨询栏目页 t一级栏目 n 二级栏目 Page 页码 size 数量
|
|
|
|
+func ColumnHome(t, n string, page, size int) (*[]map[string]interface{}, int, int, bool) {
|
|
var (
|
|
var (
|
|
data *[]map[string]interface{}
|
|
data *[]map[string]interface{}
|
|
isTurn bool
|
|
isTurn bool
|
|
count, total int
|
|
count, total int
|
|
)
|
|
)
|
|
- query := map[string]interface{}{"type": t, "name": n}
|
|
|
|
- data = mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, nil, false, (page-1)*size, size)
|
|
|
|
- count = mongodb.Count("jy_course", query)
|
|
|
|
|
|
+ query := map[string]interface{}{"s_contenttype": t, "s_secondclassifytype": n}
|
|
|
|
+ data = mongodb.Find("content", query, `{"l_publishtime":-1}`, nil, false, (page-1)*size, size)
|
|
|
|
+ count = mongodb.Count("content", query)
|
|
total = int(math.Ceil(float64(count) / float64(size)))
|
|
total = int(math.Ceil(float64(count) / float64(size)))
|
|
if page < total {
|
|
if page < total {
|
|
isTurn = true
|
|
isTurn = true
|
|
@@ -134,7 +134,7 @@ func StrategyColumn(t, n, page, size int) (*[]map[string]interface{}, int, int,
|
|
return data, count, total, isTurn
|
|
return data, count, total, isTurn
|
|
}
|
|
}
|
|
|
|
|
|
-// Consultation (栏目页)热点咨询,重要咨询
|
|
|
|
|
|
+// Consultation (攻略栏目页)热点咨询,重要咨询
|
|
// n 当前栏目 i 获取多少条
|
|
// n 当前栏目 i 获取多少条
|
|
func Consultation(n string, num int) map[string]interface{} {
|
|
func Consultation(n string, num int) map[string]interface{} {
|
|
var (
|
|
var (
|
|
@@ -142,8 +142,8 @@ func Consultation(n string, num int) map[string]interface{} {
|
|
)
|
|
)
|
|
req := make(map[string]interface{})
|
|
req := make(map[string]interface{})
|
|
//热点咨询
|
|
//热点咨询
|
|
- query := map[string]interface{}{"type": 1} //调用行业资讯板块内内容 随机显示10篇
|
|
|
|
- data1 := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, nil, false, 0, 500)
|
|
|
|
|
|
+ query := map[string]interface{}{"s_contenttype": "xyzx"} //调用行业资讯板块内内容 随机显示10篇
|
|
|
|
+ data1 := mongodb.Find("content", query, `{"l_publishtime":-1}`, nil, false, 0, 500)
|
|
if data1 != nil {
|
|
if data1 != nil {
|
|
if len(*data1) > num {
|
|
if len(*data1) > num {
|
|
for _, v := range generateRandomNumber(0, len(*data1), num) {
|
|
for _, v := range generateRandomNumber(0, len(*data1), num) {
|
|
@@ -156,11 +156,11 @@ func Consultation(n string, num int) map[string]interface{} {
|
|
IdFormat(&res1)
|
|
IdFormat(&res1)
|
|
req["hotspot"] = res1
|
|
req["hotspot"] = res1
|
|
//重要咨询 important
|
|
//重要咨询 important
|
|
- query["type"] = 2 //调用招投标攻略的当前栏目外的其他栏目内容
|
|
|
|
- query["name"] = map[string]interface{}{
|
|
|
|
|
|
+ query["s_contenttype"] = "ztbgl" //调用招投标攻略的当前栏目外的其他栏目内容
|
|
|
|
+ query["s_secondclassifytype"] = map[string]interface{}{
|
|
"$nin": n,
|
|
"$nin": n,
|
|
}
|
|
}
|
|
- data2 := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, nil, false, 0, 500)
|
|
|
|
|
|
+ data2 := mongodb.Find("content", query, `{"l_publishtime":-1}`, nil, false, 0, 500)
|
|
if data2 != nil {
|
|
if data2 != nil {
|
|
if len(*data2) > num {
|
|
if len(*data2) > num {
|
|
for _, v := range generateRandomNumber(0, len(*data2), num) {
|
|
for _, v := range generateRandomNumber(0, len(*data2), num) {
|
|
@@ -204,18 +204,18 @@ func generateRandomNumber(start int, end int, count int) []int {
|
|
return nums
|
|
return nums
|
|
}
|
|
}
|
|
|
|
|
|
-// ArticleRecommendation 攻略详情页 内容推荐&重要咨询
|
|
|
|
|
|
+// ArticleRecommendation 攻略&资讯详情页 内容推荐&重要咨询
|
|
// 传参 t 一级栏目 num数量
|
|
// 传参 t 一级栏目 num数量
|
|
-func ArticleRecommendation(t, num int) map[string]interface{} {
|
|
|
|
|
|
+func ArticleRecommendation(t string, num int) map[string]interface{} {
|
|
//用招投标攻略文章最新10篇&随机调用招投标攻略文章,显示10篇
|
|
//用招投标攻略文章最新10篇&随机调用招投标攻略文章,显示10篇
|
|
var (
|
|
var (
|
|
res1, res2 []map[string]interface{}
|
|
res1, res2 []map[string]interface{}
|
|
)
|
|
)
|
|
query := map[string]interface{}{
|
|
query := map[string]interface{}{
|
|
- "type": t, //一级栏目
|
|
|
|
- //"name": 1, //二级栏目
|
|
|
|
|
|
+ "s_contenttype": t, //一级栏目
|
|
|
|
+ //"s_secondclassifytype": 1, //二级栏目
|
|
}
|
|
}
|
|
- article := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, `{"_id":1,"title":1,"l_publishtime":1}`, false, 0, 500)
|
|
|
|
|
|
+ article := mongodb.Find("content", query, `{"l_publishtime":-1}`, `{"_id":1,"title":1,"l_publishtime":1}`, false, 0, 500)
|
|
if article != nil {
|
|
if article != nil {
|
|
if len(*article) > num {
|
|
if len(*article) > num {
|
|
res1 = (*article)[:num]
|
|
res1 = (*article)[:num]
|
|
@@ -235,49 +235,49 @@ func ArticleRecommendation(t, num int) map[string]interface{} {
|
|
// SearchList 搜索search t 1级栏目 n 2级栏目
|
|
// SearchList 搜索search t 1级栏目 n 2级栏目
|
|
// 传参 keyWord 关键词 t 一级栏目 n二级栏目 page分页 size 数量
|
|
// 传参 keyWord 关键词 t 一级栏目 n二级栏目 page分页 size 数量
|
|
// list数据 总数,总页, isTurn 是否可以翻页 搜索数量为0时 相关推荐:latestPush 最新 randomExtraction 随机
|
|
// list数据 总数,总页, isTurn 是否可以翻页 搜索数量为0时 相关推荐:latestPush 最新 randomExtraction 随机
|
|
-func SearchList(keyWord string, t, n, page, size int) ([]map[string]interface{}, int, int, bool, map[string]interface{}) {
|
|
|
|
|
|
+func SearchList(keyWord, t, n string, page, size int) ([]map[string]interface{}, int, int, bool, map[string]interface{}) {
|
|
var (
|
|
var (
|
|
isTurn bool
|
|
isTurn bool
|
|
count, total int
|
|
count, total int
|
|
)
|
|
)
|
|
res := make(map[string]interface{})
|
|
res := make(map[string]interface{})
|
|
query := map[string]interface{}{
|
|
query := map[string]interface{}{
|
|
- "type": t, //一级栏目
|
|
|
|
- "name": n, //二级栏目
|
|
|
|
|
|
+ "s_contenttype": t, //一级栏目
|
|
|
|
+ "s_secondclassifytype": n, //二级栏目
|
|
"title": map[string]interface{}{
|
|
"title": map[string]interface{}{
|
|
"$regex": keyWord,
|
|
"$regex": keyWord,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
var list *[]map[string]interface{}
|
|
var list *[]map[string]interface{}
|
|
- list = mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, `{"_id":1,"title":1,"l_publishtime":1,"text":1}`, false, (page-1)*size, size)
|
|
|
|
- count = mongodb.Count("jy_course", query)
|
|
|
|
|
|
+ list = mongodb.Find("content", query, `{"l_publishtime":-1}`, `{"_id":1,"title":1,"l_publishtime":1,"text":1}`, false, (page-1)*size, size)
|
|
|
|
+ count = mongodb.Count("content", query)
|
|
total = int(math.Ceil(float64(count) / float64(size)))
|
|
total = int(math.Ceil(float64(count) / float64(size)))
|
|
if page < total {
|
|
if page < total {
|
|
isTurn = true
|
|
isTurn = true
|
|
}
|
|
}
|
|
if count == 0 {
|
|
if count == 0 {
|
|
//获取最新攻略文章 &随机攻略文章
|
|
//获取最新攻略文章 &随机攻略文章
|
|
- res = ArticleRecommendation(1, 5)
|
|
|
|
|
|
+ res = ArticleRecommendation(t, 5)
|
|
}
|
|
}
|
|
IdFormat(list)
|
|
IdFormat(list)
|
|
return *list, count, total, isTurn, res
|
|
return *list, count, total, isTurn, res
|
|
}
|
|
}
|
|
|
|
|
|
-// GuidelineDetails 招标攻略详情 t 一级栏目,二级栏目,id
|
|
|
|
|
|
+// GuidelineDetails 详情页 t 一级栏目,二级栏目,id
|
|
// 返回详情,上一页id 下一页id 相关推荐
|
|
// 返回详情,上一页id 下一页id 相关推荐
|
|
// 传参 t 一级栏目 i 二级栏目 ids 加密id
|
|
// 传参 t 一级栏目 i 二级栏目 ids 加密id
|
|
-func GuidelineDetails(t, i int, keyWord, ids string) (map[string]interface{}, string, string, []map[string]interface{}) {
|
|
|
|
|
|
+func GuidelineDetails(t, i string, keyWord, ids string) (map[string]interface{}, string, string, []map[string]interface{}) {
|
|
var (
|
|
var (
|
|
isOn, isUnder string
|
|
isOn, isUnder string
|
|
)
|
|
)
|
|
res := make(map[string]interface{})
|
|
res := make(map[string]interface{})
|
|
id, _ := jy.AC.Decrypt(ids)
|
|
id, _ := jy.AC.Decrypt(ids)
|
|
query := map[string]interface{}{
|
|
query := map[string]interface{}{
|
|
- "type": t, //一级栏目
|
|
|
|
- "name": i, //2级栏目
|
|
|
|
- "_id": bson.ObjectIdHex(id),
|
|
|
|
|
|
+ "s_contenttype": t, //一级栏目
|
|
|
|
+ "s_secondclassifytype": i, //2级栏目
|
|
|
|
+ "_id": bson.ObjectIdHex(id),
|
|
}
|
|
}
|
|
- data := mongodb.FindOne("jy_course", query)
|
|
|
|
|
|
+ data := mongodb.FindOne("content", query)
|
|
if data != nil && len(*data) > 0 {
|
|
if data != nil && len(*data) > 0 {
|
|
(*data)["_id"], _ = jy.AC.Encrypt(id) //Decrypt
|
|
(*data)["_id"], _ = jy.AC.Encrypt(id) //Decrypt
|
|
res = *data
|
|
res = *data
|
|
@@ -294,7 +294,7 @@ func GuidelineDetails(t, i int, keyWord, ids string) (map[string]interface{}, st
|
|
"$regex": keyWord,
|
|
"$regex": keyWord,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- dataOn := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, `{"_id":1}`, false, 0, 1)
|
|
|
|
|
|
+ dataOn := mongodb.Find("content", query, `{"l_publishtime":-1}`, `{"_id":1}`, false, 0, 1)
|
|
if data != nil && len(*dataOn) > 0 {
|
|
if data != nil && len(*dataOn) > 0 {
|
|
isOn, _ = jy.AC.Encrypt(util.InterfaceToStr((*dataOn)[0]["_id"]))
|
|
isOn, _ = jy.AC.Encrypt(util.InterfaceToStr((*dataOn)[0]["_id"]))
|
|
}
|
|
}
|
|
@@ -304,20 +304,20 @@ func GuidelineDetails(t, i int, keyWord, ids string) (map[string]interface{}, st
|
|
"$gt": publishtime,
|
|
"$gt": publishtime,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
- dataUnder := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, `{"_id":1}`, false, 0, 1)
|
|
|
|
|
|
+ dataUnder := mongodb.Find("content", query, `{"l_publishtime":-1}`, `{"_id":1}`, false, 0, 1)
|
|
if dataUnder != nil && len(*dataUnder) > 0 {
|
|
if dataUnder != nil && len(*dataUnder) > 0 {
|
|
isUnder, _ = jy.AC.Encrypt(util.InterfaceToStr((*dataUnder)[0]["_id"]))
|
|
isUnder, _ = jy.AC.Encrypt(util.InterfaceToStr((*dataUnder)[0]["_id"]))
|
|
}
|
|
}
|
|
//相关内容推荐
|
|
//相关内容推荐
|
|
recommendQuery := map[string]interface{}{
|
|
recommendQuery := map[string]interface{}{
|
|
- "type": t, //一级栏目
|
|
|
|
- "name": i, //2级栏目
|
|
|
|
|
|
+ "s_contenttype": t, //一级栏目
|
|
|
|
+ "s_secondclassifytype": i, //2级栏目
|
|
"_id": map[string]interface{}{
|
|
"_id": map[string]interface{}{
|
|
"$nin": bson.ObjectIdHex(id),
|
|
"$nin": bson.ObjectIdHex(id),
|
|
},
|
|
},
|
|
}
|
|
}
|
|
var recommend []map[string]interface{}
|
|
var recommend []map[string]interface{}
|
|
- dataRe := mongodb.Find("jy_course", recommendQuery, `{"l_publishtime":-1}`, `{"_id":1}`, false, 0, 500)
|
|
|
|
|
|
+ dataRe := mongodb.Find("content", recommendQuery, `{"l_publishtime":-1}`, `{"_id":1}`, false, 0, 500)
|
|
if dataRe != nil {
|
|
if dataRe != nil {
|
|
if len(*dataRe) > 3 {
|
|
if len(*dataRe) > 3 {
|
|
for _, key := range generateRandomNumber(0, len(*data), 3) {
|
|
for _, key := range generateRandomNumber(0, len(*data), 3) {
|
|
@@ -335,13 +335,13 @@ func GuidelineDetails(t, i int, keyWord, ids string) (map[string]interface{}, st
|
|
func AddNumberViews(ids string) {
|
|
func AddNumberViews(ids string) {
|
|
var number int
|
|
var number int
|
|
id, _ := jy.AC.Decrypt(ids)
|
|
id, _ := jy.AC.Decrypt(ids)
|
|
- data := mongodb.FindById("jy_course", id, `{"number":1}`)
|
|
|
|
|
|
+ data := mongodb.FindById("content", id, `{"number":1}`)
|
|
if data != nil && len(*data) > 0 {
|
|
if data != nil && len(*data) > 0 {
|
|
//+1
|
|
//+1
|
|
number = util.IntAll((*data)["number"]) + 1
|
|
number = util.IntAll((*data)["number"]) + 1
|
|
}
|
|
}
|
|
|
|
|
|
- mongodb.Update("jy_course", map[string]interface{}{"_id": bson.ObjectIdHex(id)},
|
|
|
|
|
|
+ mongodb.Update("content", map[string]interface{}{"_id": bson.ObjectIdHex(id)},
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"number": number,
|
|
"number": number,
|