|
@@ -6,7 +6,6 @@ import (
|
|
|
"github.com/go-xweb/xweb"
|
|
|
"github.com/p/mahonia"
|
|
|
"html/template"
|
|
|
- "log"
|
|
|
"qfw/coreutil"
|
|
|
"qfw/mobile"
|
|
|
. "qfw/util"
|
|
@@ -14,7 +13,6 @@ import (
|
|
|
"qfw/util/elastic"
|
|
|
ip "qfw/util/ip17mon"
|
|
|
. "qfw/util/mongodb"
|
|
|
- "qfw/util/redis"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -31,11 +29,9 @@ func (n *Wxsearch) WxIndex() error {
|
|
|
func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
n.T["signature"] = mobile.GetSignature(n.Url())
|
|
|
i_mingpian := n.GetString("i_mingpian") //是否走名片查询
|
|
|
- log.Println(n.Method())
|
|
|
if n.Method() == "POST" {
|
|
|
//请求是表单提交,走的查询
|
|
|
//拼装查询对象
|
|
|
- log.Println("进入POST查找")
|
|
|
querymap := map[string]string{ //"words": n.GetString("s_value"),
|
|
|
"perPage": "20",
|
|
|
"currentPage": n.GetString("currentPage"),
|
|
@@ -47,7 +43,6 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
"c_author": n.GetString("c_author"),
|
|
|
"cityNo": n.GetString("cityNo"), //是否是第一次查询并且没有选择地市,自动根据IP来设
|
|
|
}
|
|
|
- log.Println(querymap, "---------------------------", n, reqType)
|
|
|
//查询生成列表数据
|
|
|
var data *[]map[string]interface{}
|
|
|
if i_mingpian != "" {
|
|
@@ -55,9 +50,7 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
} else {
|
|
|
data = wxsearhWebContentent(querymap, n, reqType)
|
|
|
}
|
|
|
- log.Println(data)
|
|
|
rs := FormatData(data)
|
|
|
- log.Println(rs)
|
|
|
querymap["entcard"] = n.GetString("mingpian")
|
|
|
if n.GetString("currentPage") != "" {
|
|
|
return n.Write(rs)
|
|
@@ -134,24 +127,9 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
|
|
|
tn, er := ip.Find(n.Protocol())
|
|
|
if nil == er {
|
|
|
switch tn.Region {
|
|
|
- case "河南", "广西", "黑龙江", "青海", "西藏", "安徽", "山西":
|
|
|
+ case "北京", "天津", "河北", "山西", "内蒙古", "辽宁", "吉林", "黑龙江", "上海", "江苏", "浙江", "安徽", "福建", "江西", "山东", "广东", "广西", "海南", "河南", "湖北", "湖南", "重庆", "四川", "贵州", "云南", "西藏", "陕西", "甘肃", "青海", "宁夏", "新疆":
|
|
|
ipcity = consts.Scode[tn.Region]
|
|
|
if len(ipcity) > 0 {
|
|
|
- tmp_res := redis.Get("enterprise", "wx_ipcity_"+ipcity+"_1")
|
|
|
- if nil != tmp_res {
|
|
|
- tmp_res1, oks1 := tmp_res.([]interface{})
|
|
|
-
|
|
|
- if tmp_res1 != nil && oks1 {
|
|
|
- tmp_resn := make([]map[string]interface{}, len(tmp_res1))
|
|
|
- for k := 0; k < len(tmp_res1); k++ {
|
|
|
- tmp_resn1, _ := tmp_res1[k].(map[string]interface{})
|
|
|
- tmp_resn[k] = tmp_resn1
|
|
|
- }
|
|
|
- return &tmp_resn
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //str += `{"prefix":{"OpLocDistrict":"` + ipcity + `"}}`
|
|
|
tempBisOne = true
|
|
|
query = `{"query": {
|
|
|
"function_score": {
|
|
@@ -161,7 +139,7 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
|
|
|
}
|
|
|
}
|
|
|
,"_source":["_id","EntName","RegOrgName","RegNo","EntType","LeRep","EstDate","OpLocDistrictName","RegCap","OpStateName","OpState","s_servicenames","s_action","OpLocDistrict","RegCapCurName","s_avatar"]
|
|
|
- ,"from":0,
|
|
|
+ ,"from": ` + fmt.Sprintf("%v", ((currentPage-1)*perPage)) + `,
|
|
|
"size":` + fmt.Sprintf("%v", perPage) + `,
|
|
|
"sort": [{"_score": "desc"},{"OpSint":"desc"},{"RegCap":"desc"}]
|
|
|
}`
|
|
@@ -306,7 +284,6 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
|
|
|
"size":` + fmt.Sprintf("%v", perPage) +
|
|
|
`,"sort":[` + sort + `] }`
|
|
|
}
|
|
|
-
|
|
|
//查询列表数据
|
|
|
client := elastic.GetEsConn()
|
|
|
defer elastic.DestoryEsConn(client)
|
|
@@ -400,9 +377,6 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if tempBisOne && len(ipcity) > 0 {
|
|
|
- redis.Put("enterprise", "wx_ipcity_"+ipcity+"_1", res, 5*86400)
|
|
|
- }
|
|
|
return &res
|
|
|
}
|
|
|
|