소스 검색

feat:未登录用户搜索条数限制

duxin 2 년 전
부모
커밋
846e1968ff
2개의 변경된 파일15개의 추가작업 그리고 14개의 파일을 삭제
  1. 3 0
      jyBXCore/rpc/internal/logic/getsearchlistlogic.go
  2. 12 14
      jyBXCore/rpc/util/search.go

+ 3 - 0
jyBXCore/rpc/internal/logic/getsearchlistlogic.go

@@ -168,6 +168,9 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 				}
 				}
 			}
 			}
 			limitCount := MC.If(in.UserType != "fType", int64(util.SearchPageSize*util.SearchMaxPageNum_PAYED), int64(util.SearchPageSize*util.SearchMaxPageNum)).(int64)
 			limitCount := MC.If(in.UserType != "fType", int64(util.SearchPageSize*util.SearchMaxPageNum_PAYED), int64(util.SearchPageSize*util.SearchMaxPageNum)).(int64)
+			if in.UserId == "" {
+				limitCount = util.SearchMaxPageCount_NOLOGIN
+			}
 			if count > limitCount {
 			if count > limitCount {
 				count = limitCount
 				count = limitCount
 			}
 			}

+ 12 - 14
jyBXCore/rpc/util/search.go

@@ -62,8 +62,8 @@ func FilteKey(k string) string {
 	return k
 	return k
 }
 }
 
 
-//超过keywordsLimit个字,截断
-//返回截取后的字符串和截取掉中的前3个字
+// 超过keywordsLimit个字,截断
+// 返回截取后的字符串和截取掉中的前3个字
 func InterceptSearchKW(word string, keywordsLimit int, isFilter bool) (b_word, a_word, s_word string) {
 func InterceptSearchKW(word string, keywordsLimit int, isFilter bool) (b_word, a_word, s_word string) {
 	if isFilter {
 	if isFilter {
 		word = FilteKey(word)
 		word = FilteKey(word)
@@ -129,7 +129,6 @@ func HttpEs(ques, analyzer, esAddress string) (res string) {
 	return
 	return
 }
 }
 
 
-//
 func getesResp(ques, analyzer string, addrs []string) (resp *http.Response, err error) {
 func getesResp(ques, analyzer string, addrs []string) (resp *http.Response, err error) {
 	for _, v := range addrs {
 	for _, v := range addrs {
 		surl := v + "/bidding/_analyze"
 		surl := v + "/bidding/_analyze"
@@ -156,8 +155,9 @@ const (
 	//招标搜索分页--每页显示数量
 	//招标搜索分页--每页显示数量
 	SearchPageSize = 50
 	SearchPageSize = 50
 	//招标搜索分页--最大页数
 	//招标搜索分页--最大页数
-	SearchMaxPageNum       = 10  //免费用户500条记录
-	SearchMaxPageNum_PAYED = 100 //付费用户5000条记录
+	SearchMaxPageNum           = 10   //免费用户500条记录
+	SearchMaxPageNum_PAYED     = 100  //付费用户5000条记录
+	SearchMaxPageCount_NOLOGIN = 5000 //未登录用户5000条记录
 
 
 	bidSearch_field_1    = `"_id","title","publishtime","dataweight","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass","spidercode","site"` //,"filetext"
 	bidSearch_field_1    = `"_id","title","publishtime","dataweight","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass","spidercode","site"` //,"filetext"
 	bidSearch_field      = bidSearch_field_1 + `,"bidopentime","winner","buyer","projectname","projectcode","projectinfo"`
 	bidSearch_field      = bidSearch_field_1 + `,"bidopentime","winner","buyer","projectname","projectcode","projectinfo"`
@@ -165,7 +165,7 @@ const (
 	query_bool_should    = `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	query_bool_should    = `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 )
 )
 
 
-//GetBidSearchData 标信息搜索
+// GetBidSearchData 标信息搜索
 func GetBidSearchData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchList) {
 func GetBidSearchData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchList) {
 	t := time.Now()
 	t := time.Now()
 	var hightlightContent bool = false //是否高亮正文
 	var hightlightContent bool = false //是否高亮正文
@@ -216,7 +216,6 @@ func GetBidSearchData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchL
 	return
 	return
 }
 }
 
 
-//
 var topTypeMap = map[string]string{
 var topTypeMap = map[string]string{
 	"招标预告":   "预告",
 	"招标预告":   "预告",
 	"招标公告":   "招标",
 	"招标公告":   "招标",
@@ -226,7 +225,6 @@ var topTypeMap = map[string]string{
 	"采购意向":   "采购意向",
 	"采购意向":   "采购意向",
 }
 }
 
 
-//
 func GetBidSearchQuery(in *bxcore.SearchReq) string {
 func GetBidSearchQuery(in *bxcore.SearchReq) string {
 	query := ``
 	query := ``
 	//省份
 	//省份
@@ -340,7 +338,7 @@ func GetBidSearchQuery(in *bxcore.SearchReq) string {
 	return query
 	return query
 }
 }
 
 
-//包含正文或 附件 不包含标题
+// 包含正文或 附件 不包含标题
 func DetailFileORTitle(findfields string) bool {
 func DetailFileORTitle(findfields string) bool {
 	return (strings.Contains(findfields, `"detail"`) || strings.Contains(findfields, `"filetext"`)) && !strings.Contains(findfields, `"title"`)
 	return (strings.Contains(findfields, `"detail"`) || strings.Contains(findfields, `"filetext"`)) && !strings.Contains(findfields, `"title"`)
 }
 }
@@ -549,7 +547,7 @@ func BidListConvert(industry string, res *[]map[string]interface{}) {
 	}
 	}
 }
 }
 
 
-//是否收藏
+// 是否收藏
 func MakeCollection(userId string, list []*bxcore.SearchList) {
 func MakeCollection(userId string, list []*bxcore.SearchList) {
 	if list == nil || len(list) == 0 {
 	if list == nil || len(list) == 0 {
 		return
 		return
@@ -579,7 +577,7 @@ func MakeCollection(userId string, list []*bxcore.SearchList) {
 	}
 	}
 }
 }
 
 
-//默认查询缓存数据
+// 默认查询缓存数据
 func SearchCahcheData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchList) {
 func SearchCahcheData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchList) {
 	//最新招标信息
 	//最新招标信息
 	findfields := `"title"`
 	findfields := `"title"`
@@ -598,7 +596,7 @@ func SearchCahcheData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchL
 	return
 	return
 }
 }
 
 
-//格式化数据
+// 格式化数据
 func searchListFormart(repl *[]map[string]interface{}, b bool) (list []*bxcore.SearchList) {
 func searchListFormart(repl *[]map[string]interface{}, b bool) (list []*bxcore.SearchList) {
 	for _, v := range *repl {
 	for _, v := range *repl {
 		var searchList = &bxcore.SearchList{}
 		var searchList = &bxcore.SearchList{}
@@ -648,7 +646,7 @@ func searchListFormart(repl *[]map[string]interface{}, b bool) (list []*bxcore.S
 	return
 	return
 }
 }
 
 
-//合并map数据,去重,排序
+// 合并map数据,去重,排序
 func DelRepeatSearchData(resOne, resTwo []*bxcore.SearchList) []*bxcore.SearchList {
 func DelRepeatSearchData(resOne, resTwo []*bxcore.SearchList) []*bxcore.SearchList {
 	if len(resOne) > 0 && len(resTwo) > 0 {
 	if len(resOne) > 0 && len(resTwo) > 0 {
 		for _, v := range resOne {
 		for _, v := range resOne {
@@ -669,7 +667,7 @@ func DelRepeatSearchData(resOne, resTwo []*bxcore.SearchList) []*bxcore.SearchLi
 	return resOne
 	return resOne
 }
 }
 
 
-//付费用户搜索优化
+// 付费用户搜索优化
 func IsOptimize(cc config.Config, in *bxcore.SearchReq) bool {
 func IsOptimize(cc config.Config, in *bxcore.SearchReq) bool {
 	if cc.PaySearchLimit.Switch && in.UserType != "fType" {
 	if cc.PaySearchLimit.Switch && in.UserType != "fType" {
 		//首页----字数(<7)
 		//首页----字数(<7)