|
@@ -33,9 +33,9 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
- bidSearch_field_1 = `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass","spidercode","site"`
|
|
|
|
|
|
+ bidSearch_field_1 = `"_id","title","publishtime","toptype","subtype","type","area","dataweight","city","s_subscopeclass","bidamount","budget","buyerclass","spidercode","site"`
|
|
bidSearch_field = bidSearch_field_1 + `,"bidopentime","winner","buyer","projectname","projectcode","projectinfo"`
|
|
bidSearch_field = bidSearch_field_1 + `,"bidopentime","winner","buyer","projectname","projectcode","projectinfo"`
|
|
- bidSearch_sort = `{"publishtime":-1}`
|
|
|
|
|
|
+ bidSearch_sort = `{"dataweight":-1,"publishtime":-1}`
|
|
bidSearch_field_file = `,"filetext","isValidFile"`
|
|
bidSearch_field_file = `,"filetext","isValidFile"`
|
|
)
|
|
)
|
|
|
|
|
|
@@ -1364,7 +1364,6 @@ func (f *Front) Jyblog(param /*参数*/ string) error {
|
|
paramstr := param[1:]
|
|
paramstr := param[1:]
|
|
bs, _ := base64.StdEncoding.DecodeString(paramstr)
|
|
bs, _ := base64.StdEncoding.DecodeString(paramstr)
|
|
json.Unmarshal(bs, &querymap)
|
|
json.Unmarshal(bs, &querymap)
|
|
-
|
|
|
|
}
|
|
}
|
|
var shareid = f.GetString("id")
|
|
var shareid = f.GetString("id")
|
|
if len(shareid) == 0 {
|
|
if len(shareid) == 0 {
|
|
@@ -1391,92 +1390,66 @@ func SearhWebContentblog(querymap map[string]string) (*[]map[string]interface{},
|
|
}
|
|
}
|
|
contentType := querymap["contentType"]
|
|
contentType := querymap["contentType"]
|
|
queryStr := querymap["query"]
|
|
queryStr := querymap["query"]
|
|
- str := ``
|
|
|
|
|
|
+
|
|
|
|
+ queryMap := map[string]interface{}{
|
|
|
|
+ "s_contenttype": contentType,
|
|
|
|
+ }
|
|
|
|
+
|
|
if queryStr != "" {
|
|
if queryStr != "" {
|
|
- str = `{
|
|
|
|
- "match": {
|
|
|
|
- "s_title": {
|
|
|
|
- "query":"` + queryStr + `",
|
|
|
|
- "operator": "and"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },{
|
|
|
|
- "match": {
|
|
|
|
- "s_content": {
|
|
|
|
- "query":"` + queryStr + `"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }`
|
|
|
|
- }
|
|
|
|
- var tempQuery = `{"query": {
|
|
|
|
- "bool": {
|
|
|
|
- "must":[{"term":{"s_contenttype":"` + contentType + `"}}],
|
|
|
|
- "should": [` + str + `],
|
|
|
|
- "minimum_should_match": 0
|
|
|
|
- }
|
|
|
|
- }}`
|
|
|
|
- var query = tempQuery[:len(tempQuery)-1] +
|
|
|
|
- `,"highlight":{
|
|
|
|
- "pre_tags":["<span class='highlight'>"],
|
|
|
|
- "post_tags":["</span>"],
|
|
|
|
- "fields":{
|
|
|
|
- "s_title":{"force_source": true}
|
|
|
|
- ,"s_content":{"force_source": true}
|
|
|
|
- }
|
|
|
|
- },"_source":["s_title","s_date","s_contenttype","s_content","releasetime","s_description","praise","s_source","s_pic","s_pic1","l_createdate","s_code","_id","s_author"]
|
|
|
|
- ,"from":` + fmt.Sprintf("%v", ((currentPage-1)*perPage)) + `,
|
|
|
|
- "size":` + fmt.Sprintf("%v", perPage) +
|
|
|
|
- `,"sort":[{"releasetime":{"order":"desc"}}] }`
|
|
|
|
-
|
|
|
|
- total := elastic.Count("content", "content", tempQuery)
|
|
|
|
|
|
+ queryMap["$or"] = []interface{}{
|
|
|
|
+ map[string]interface{}{
|
|
|
|
+ "s_title": map[string]interface{}{"$regex": queryStr},
|
|
|
|
+ },
|
|
|
|
+ map[string]interface{}{
|
|
|
|
+ "s_content": map[string]interface{}{"$regex": queryStr},
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ total := public.MQFW.Count("content", queryMap)
|
|
|
|
+
|
|
//查询列表数据
|
|
//查询列表数据
|
|
client := elastic.GetEsConn()
|
|
client := elastic.GetEsConn()
|
|
defer elastic.DestoryEsConn(client)
|
|
defer elastic.DestoryEsConn(client)
|
|
if client == nil {
|
|
if client == nil {
|
|
return nil, nil
|
|
return nil, nil
|
|
}
|
|
}
|
|
- searchResult, err := client.Search().Index("content").Type("content").Source(query).Do()
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, nil
|
|
|
|
- }
|
|
|
|
|
|
+ searchResult, _ := public.MQFW.Find("content", queryMap, `{"releasetime":-1}`, `{"s_title":1,"s_contenttype":1,"s_content":1,"releasetime":1,"s_description":1,"praise":1,"s_source":1,"s_pic":1,"s_pic1":1,"l_createdate":1,"_id":1,"s_author":1}`, false, (currentPage-1)*perPage, perPage)
|
|
|
|
+
|
|
var res []map[string]interface{}
|
|
var res []map[string]interface{}
|
|
- if searchResult.Hits != nil {
|
|
|
|
- resNum := len(searchResult.Hits.Hits)
|
|
|
|
- res = make([]map[string]interface{}, resNum)
|
|
|
|
- for i, hit := range searchResult.Hits.Hits {
|
|
|
|
- json.Unmarshal(*hit.Source, &res[i])
|
|
|
|
- //查询结果数据加工处理
|
|
|
|
- for k, v := range hit.Highlight {
|
|
|
|
- res[i][k] = v[0]
|
|
|
|
- }
|
|
|
|
- s_content, _ := res[i]["s_content"].(string)
|
|
|
|
|
|
+ if searchResult != nil && len(*searchResult) > 0 {
|
|
|
|
+ for _, m := range *searchResult {
|
|
|
|
+ s_content, _ := m["s_content"].(string)
|
|
if len(s_content) > 500 {
|
|
if len(s_content) > 500 {
|
|
- res[i]["s_content"] = ""
|
|
|
|
|
|
+ m["s_content"] = ""
|
|
} else {
|
|
} else {
|
|
con, _ := regexp.Compile("^[^<]*?>")
|
|
con, _ := regexp.Compile("^[^<]*?>")
|
|
content := con.ReplaceAllString(s_content, "")
|
|
content := con.ReplaceAllString(s_content, "")
|
|
con1, _ := regexp.Compile("<[^>]*$")
|
|
con1, _ := regexp.Compile("<[^>]*$")
|
|
- res[i]["s_content"] = template.HTML(con1.ReplaceAllString(content, ""))
|
|
|
|
- }
|
|
|
|
- s_title, _ := res[i]["s_title"].(string)
|
|
|
|
- res[i]["s_title"] = template.HTML(s_title)
|
|
|
|
- tmpdate, _ := res[i]["l_createdate"]
|
|
|
|
- res[i]["l_createdate"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate.(float64)), 0))
|
|
|
|
- tmpdate1, _ := res[i]["releasetime"]
|
|
|
|
- res[i]["releasetime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate1.(float64)), 0))
|
|
|
|
- reltime := time.Unix(util.Int64All(tmpdate1.(float64)), 0)
|
|
|
|
- res[i]["time"] = reltime.Format(util.Date_Short_Layout) //首页展示
|
|
|
|
- s_pic, _ := res[i]["s_pic"].(string)
|
|
|
|
|
|
+ m["s_content"] = template.HTML(con1.ReplaceAllString(content, ""))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ s_title, _ := m["s_title"].(string)
|
|
|
|
+ m["s_title"] = template.HTML(s_title)
|
|
|
|
+
|
|
|
|
+ tmpdate, _ := m["l_createdate"]
|
|
|
|
+ m["l_createdate"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate), 0))
|
|
|
|
+ tmpdate1, _ := m["releasetime"]
|
|
|
|
+ m["releasetime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate1), 0))
|
|
|
|
+ reltime := time.Unix(util.Int64All(tmpdate1), 0)
|
|
|
|
+ m["time"] = reltime.Format(util.Date_Short_Layout) //首页展示
|
|
|
|
+ s_pic, _ := m["s_pic"].(string)
|
|
if s_pic != "" {
|
|
if s_pic != "" {
|
|
s_pic = config.Seoconfig["jyadd"].(string) + s_pic
|
|
s_pic = config.Seoconfig["jyadd"].(string) + s_pic
|
|
}
|
|
}
|
|
- res[i]["s_pic"] = s_pic
|
|
|
|
- s_pic1, _ := res[i]["s_pic1"].(string)
|
|
|
|
|
|
+ m["s_pic"] = s_pic
|
|
|
|
+ s_pic1, _ := m["s_pic1"].(string)
|
|
if s_pic1 != "" {
|
|
if s_pic1 != "" {
|
|
s_pic1 = config.Seoconfig["jyadd"].(string) + s_pic1
|
|
s_pic1 = config.Seoconfig["jyadd"].(string) + s_pic1
|
|
}
|
|
}
|
|
- res[i]["s_pic1"] = s_pic1
|
|
|
|
- res[i]["_id"] = se.EncodeString(res[i]["_id"].(string))
|
|
|
|
|
|
+ m["s_pic1"] = s_pic1
|
|
|
|
+ m["_id"] = se.EncodeString(BsonIdToSId(m["_id"]))
|
|
|
|
+ res = append(res, m)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//生成分页
|
|
//生成分页
|
|
@@ -1522,6 +1495,17 @@ func MakePagination(perPage, currentPage, total int, param map[string]string, ur
|
|
url = fmt.Sprintf(urltpl, paramstr)
|
|
url = fmt.Sprintf(urltpl, paramstr)
|
|
iscurrent = currentPage == totalPages
|
|
iscurrent = currentPage == totalPages
|
|
ret[index] = map[string]interface{}{"page": "下一页 >", "url": url, "iscurrent": iscurrent}
|
|
ret[index] = map[string]interface{}{"page": "下一页 >", "url": url, "iscurrent": iscurrent}
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+ u := map[string]interface{}{
|
|
|
|
+ "currentPage": 1,
|
|
|
|
+ "query": "招标",
|
|
|
|
+ "contentType": param["contentType"],
|
|
|
|
+ }
|
|
|
|
+ bs, _ = json.Marshal(u)
|
|
|
|
+ paramstr = base64.StdEncoding.EncodeToString(bs)
|
|
|
|
+ fmt.Println("ooooo", paramstr)
|
|
|
|
+
|
|
return ret
|
|
return ret
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1542,14 +1526,15 @@ func (f *Front) Jybdetail(_id string) error {
|
|
f.T["data"] = retlist
|
|
f.T["data"] = retlist
|
|
} else {
|
|
} else {
|
|
id := se.DecodeString(_id)
|
|
id := se.DecodeString(_id)
|
|
- r := elastic.GetByIdField("content", "content", id, `"_id","s_title","l_createdate","s_pic","s_author","s_editorname","s_contenttype","praise","releasetime","s_subcontent","s_url","s_content","s_source","s_keywords","s_description","s_contenttype","s_pic1"`)
|
|
|
|
|
|
+ //r := elastic.GetByIdField("content", "content", id, `"_id","s_title","l_createdate","s_pic","s_author","s_editorname","s_contenttype","praise","releasetime","s_subcontent","s_url","s_content","s_source","s_keywords","s_description","s_contenttype","s_pic1"`)
|
|
|
|
+ r, _ := public.MQFW.FindById("content", id, `{"s_title":1,"s_contenttype":1,"s_content":1,"releasetime":1,"s_description":1,"praise":1,"s_source":1,"s_pic":1,"s_pic1":1,"l_createdate":1,"_id":1,"s_author":1,"s_editorname":1,"s_url":1,"s_subcontent":1,"s_keywords":1}`)
|
|
if r != nil {
|
|
if r != nil {
|
|
tmpdate1, _ := (*r)["l_createdate"]
|
|
tmpdate1, _ := (*r)["l_createdate"]
|
|
- (*r)["l_createdate"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate1.(float64)), 0))
|
|
|
|
|
|
+ (*r)["l_createdate"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate1), 0))
|
|
tmpdate2, _ := (*r)["releasetime"]
|
|
tmpdate2, _ := (*r)["releasetime"]
|
|
- (*r)["releasetime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate2.(float64)), 0))
|
|
|
|
- (*r)["s_content"] = template.HTML((*r)["s_content"].(string))
|
|
|
|
- (*r)["_id"] = se.EncodeString((*r)["_id"].(string))
|
|
|
|
|
|
+ (*r)["releasetime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate2), 0))
|
|
|
|
+ (*r)["s_content"] = template.HTML(util.ObjToString((*r)["s_content"]))
|
|
|
|
+ (*r)["_id"] = se.EncodeString(BsonIdToSId((*r)["_id"]))
|
|
s_pic, _ := (*r)["s_pic"].(string)
|
|
s_pic, _ := (*r)["s_pic"].(string)
|
|
if s_pic != "" {
|
|
if s_pic != "" {
|
|
s_pic = config.Seoconfig["jyadd"].(string) + s_pic
|
|
s_pic = config.Seoconfig["jyadd"].(string) + s_pic
|