瀏覽代碼

feat:默认搜索

wangshan 2 年之前
父節點
當前提交
dde15f4f6e
共有 1 個文件被更改,包括 10 次插入31 次删除
  1. 10 31
      jyBXCore/rpc/entity/search.go

+ 10 - 31
jyBXCore/rpc/entity/search.go

@@ -15,8 +15,8 @@ import (
 )
 
 var (
-	SearchCacheKey   = "searchDataCache_%s_%s"
-	SearchCacheCount = "searchCountCache_%s_%s"
+	SearchCacheKey   = "searchDataCache_%d_%s"
+	SearchCacheCount = "searchCountCache_%d_%s"
 )
 
 type KeyWordsSearch struct{}
@@ -31,6 +31,7 @@ func (kws *KeyWordsSearch) IsEmptySearch(in *bxcore.SearchReq) bool {
 	if in.KeyWords != "" || in.Industry != "" || in.AdditionalWords != "" {
 		return false
 	}
+	//所有的未登录空搜索 缓存都最多查500条数据
 	return true
 }
 
@@ -39,10 +40,10 @@ func (kws *KeyWordsSearch) IsEmptySearch(in *bxcore.SearchReq) bool {
 func (kws *KeyWordsSearch) GetBidSearchListByCache(in *bxcore.SearchReq) (list []*bxcore.SearchList, count int64) {
 	//缓存数据 最大量是5000条  100页数据
 	l, c := func(in *bxcore.SearchReq) (list []*bxcore.SearchList, count int64) {
-		//缓存数据: kws.Platform-平台;kws.PageNum-当前页 免费用户 or 付费用户
-		redisDataKey := fmt.Sprintf(SearchCacheKey, in.Platform, MC.If(in.IsPay, "V", "F").(string))
+		//缓存数据: SearchGroup-全部;招标信息;超前项目信息;kws.PageNum-当前页 免费用户 or 付费用户
+		redisDataKey := fmt.Sprintf(SearchCacheKey, in.SearchGroup, MC.If(in.IsPay, "V", "F").(string))
 		//缓存数据总量 - 当前平台
-		redisCountKey := fmt.Sprintf(SearchCacheCount, in.Platform, MC.If(in.IsPay, "V", "F").(string))
+		redisCountKey := fmt.Sprintf(SearchCacheCount, in.SearchGroup, MC.If(in.IsPay, "V", "F").(string))
 		sCache, err := redis.GetNewBytes(util.RedisNameNew, redisDataKey)
 		count = int64(redis.GetInt(util.RedisNameNew, redisCountKey))
 		if err == nil {
@@ -87,10 +88,6 @@ func (kws *KeyWordsSearch) GetBidSearchListByCache(in *bxcore.SearchReq) (list [
 
 // DefaultSearchParamsAuto 缓存查询条件初始化
 func (kws *KeyWordsSearch) DefaultSearchParamsAuto(in *bxcore.SearchReq) {
-	//缓存数据 默认查询分组 searchGroup = 1 ,
-	//不查超前信息--招标信息类型为拟建和采购意向的信息
-	in.SearchGroup = 1
-	in.Subtype = IC.C.DefaultTopTypes[in.SearchGroup-1]
 	in.TopType = ""
 	in.City = ""
 	in.Industry = ""
@@ -101,7 +98,6 @@ func (kws *KeyWordsSearch) DefaultSearchParamsAuto(in *bxcore.SearchReq) {
 	in.Price = ""
 	in.SelectType = "title"
 	in.Province = ""
-	//in.PublishTime = ""
 }
 
 // SaveKeyWordsToHistory 保存历史记录
@@ -168,30 +164,13 @@ func (kws *KeyWordsSearch) SearchParamsHandle(in *bxcore.SearchReq) []string {
 	queryItems := userInfo.GetQueryItems(in.SelectType, IC.C.BidSearchOldUserLimit)
 	in.SelectType = strings.Join(queryItems, ",")
 	// in.SearchGroup 搜索分组 搜索分组:默认0:全部;1:招标采购公告;2:超前项目
+	//	详情页判断是否能使用超前项目  老版超级订阅、大会员、商机管理有权限
+	//(免费用户和新版超级订阅用户 有搜索权限,但是没有查看权限)
 	if in.SearchGroup < 0 || in.SearchGroup > 2 {
 		in.SearchGroup = 1
 	}
-	//判断是否能使用超前项目  老版超级订阅、大会员、商机管理有权限
-	if !(userInfo.IsOldVip || userInfo.BigMember > 0 || userInfo.EntMember > 0) {
-		in.SearchGroup = 1
-		//Subtype 包含:拟建,采购意向,则需要排除
-		if in.Subtype != "" {
-			var subtype []string
-			for _, sv := range strings.Split(in.Subtype, ",") {
-				if sv == "拟建" || sv == "采购意向" {
-					continue
-				}
-				subtype = append(subtype, sv)
-			}
-			in.Subtype = MC.If(len(subtype) > 0, strings.Join(subtype, ","), "").(string)
-		}
-	}
-	//信息类型参数为空  根据搜索分组 初始化信息类型
-	//in.SearchGroup = 0
-	if in.TopType == "" && in.Subtype == "" {
-		if in.SearchGroup > 0 && len(IC.C.DefaultTopTypes) >= int(in.SearchGroup) {
-			in.Subtype = IC.C.DefaultTopTypes[in.SearchGroup-1]
-		}
+	if in.SearchGroup > 0 && len(IC.C.DefaultTopTypes) >= int(in.SearchGroup) {
+		in.Subtype = IC.C.DefaultTopTypes[in.SearchGroup-1]
 	}
 	// in.SearchMode 搜索模式 搜索模式:0:精准搜索;1:模糊搜索
 	// 精准搜索:不分词,完全匹配;(中间带空格的关键词组自动分词)