|
@@ -12,9 +12,9 @@ import (
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
-func AdvancedProject(userid, keyWord string, types int) map[string]interface{} {
|
|
|
|
|
|
+func AdvancedProject(userid, keyWord string) map[string]interface{} {
|
|
mae := new(MarketAnalysisEntity)
|
|
mae := new(MarketAnalysisEntity)
|
|
- if !mae.KeyWordFormat(userid, keyWord, types) {
|
|
|
|
|
|
+ if !mae.KeyWordFormat(userid, keyWord) {
|
|
log.Printf("关键词格式化化失败 userid:%s", userid)
|
|
log.Printf("关键词格式化化失败 userid:%s", userid)
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -73,9 +73,8 @@ func AdvancedProject(userid, keyWord string, types int) map[string]interface{} {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (mae *MarketAnalysisEntity) KeyWordFormat(userid, keyWord string, types int) (ret bool) {
|
|
|
|
|
|
+func (mae *MarketAnalysisEntity) KeyWordFormat(userid, keyWord string) (ret bool) {
|
|
var (
|
|
var (
|
|
- arrMap []map[string]interface{}
|
|
|
|
aItems []interface{}
|
|
aItems []interface{}
|
|
)
|
|
)
|
|
switch mae.Types {
|
|
switch mae.Types {
|
|
@@ -83,36 +82,25 @@ func (mae *MarketAnalysisEntity) KeyWordFormat(userid, keyWord string, types int
|
|
//获取订阅词
|
|
//获取订阅词
|
|
aItems, ret = Subscription(userid)
|
|
aItems, ret = Subscription(userid)
|
|
//无订阅词且未搜索页面 查询搜索词
|
|
//无订阅词且未搜索页面 查询搜索词
|
|
- if !ret && types == 1 {
|
|
|
|
|
|
+ if !ret {
|
|
arrs := strings.Split(redis.GetStr("other", "s_"+userid), ",")
|
|
arrs := strings.Split(redis.GetStr("other", "s_"+userid), ",")
|
|
- if len(arrs) > 3 {
|
|
|
|
- arrs = arrs[:3]
|
|
|
|
- }
|
|
|
|
- if len(arrs) > 0 {
|
|
|
|
|
|
+ if len(arrs) == 0 && keyWord != "" {
|
|
|
|
+ //无缓存搜索词
|
|
ret = true
|
|
ret = true
|
|
- for _, v := range arrs {
|
|
|
|
- arrMap = append(arrMap, map[string]interface{}{"from": 1, "appendkey": nil, "key": processKeyword(v), "notkey": nil, "updatetime": time.Now().Unix()})
|
|
|
|
- }
|
|
|
|
- item := map[string]interface{}{
|
|
|
|
- "a_key": arrMap,
|
|
|
|
- "s_item": "未分类",
|
|
|
|
- "updatetime": time.Now().Unix(),
|
|
|
|
|
|
+ aItems = KeyFormat(strings.Split(keyWord, ","))
|
|
|
|
+ } else {
|
|
|
|
+ ret = true
|
|
|
|
+ //有缓存搜索词 取最近3个
|
|
|
|
+ if len(arrs) > 3 {
|
|
|
|
+ arrs = arrs[:3]
|
|
}
|
|
}
|
|
- aItems = append(aItems, item)
|
|
|
|
|
|
+ aItems = KeyFormat(arrs)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case 2: //超前项目
|
|
case 2: //超前项目
|
|
if keyWord != "" { //搜索页面超前项目
|
|
if keyWord != "" { //搜索页面超前项目
|
|
ret = true
|
|
ret = true
|
|
- for _, v := range strings.Split(keyWord, ",") {
|
|
|
|
- arrMap = append(arrMap, map[string]interface{}{"from": 1, "appendkey": nil, "key": processKeyword(v), "notkey": nil, "updatetime": time.Now().Unix()})
|
|
|
|
- }
|
|
|
|
- item := map[string]interface{}{
|
|
|
|
- "a_key": arrMap,
|
|
|
|
- "s_item": "未分类",
|
|
|
|
- "updatetime": time.Now().Unix(),
|
|
|
|
- }
|
|
|
|
- aItems = append(aItems, item)
|
|
|
|
|
|
+ aItems = KeyFormat(strings.Split(keyWord, ","))
|
|
} else { //没有关键词 订阅页面超前项目
|
|
} else { //没有关键词 订阅页面超前项目
|
|
//未传搜索词按照关键词匹配
|
|
//未传搜索词按照关键词匹配
|
|
aItems, ret = Subscription(userid)
|
|
aItems, ret = Subscription(userid)
|
|
@@ -130,6 +118,22 @@ func (mae *MarketAnalysisEntity) KeyWordFormat(userid, keyWord string, types int
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func KeyFormat(keyWord []string) (aItems []interface{}) {
|
|
|
|
+ var arrMap []map[string]interface{}
|
|
|
|
+ for _, v := range keyWord {
|
|
|
|
+ arrMap = append(arrMap, map[string]interface{}{"from": 1, "appendkey": nil, "key": processKeyword(v), "notkey": nil, "updatetime": time.Now().Unix()})
|
|
|
|
+ }
|
|
|
|
+ if len(arrMap) > 0 {
|
|
|
|
+ item := map[string]interface{}{
|
|
|
|
+ "a_key": arrMap,
|
|
|
|
+ "s_item": "未分类",
|
|
|
|
+ "updatetime": time.Now().Unix(),
|
|
|
|
+ }
|
|
|
|
+ aItems = append(aItems, item)
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func Subscription(userid string) (aItems []interface{}, ret bool) {
|
|
func Subscription(userid string) (aItems []interface{}, ret bool) {
|
|
var arrMap []map[string]interface{}
|
|
var arrMap []map[string]interface{}
|
|
//未传搜索词按照关键词匹配
|
|
//未传搜索词按照关键词匹配
|