Bläddra i källkod

feat:缓存数据量

wangshan 2 år sedan
förälder
incheckning
67efd08290

+ 7 - 6
jyBXCore/rpc/entity/search.go

@@ -37,7 +37,7 @@ func (kws *KeyWordsSearch) IsEmptySearch(in *bxcore.SearchReq) bool {
 
 // GetBidSearchListByCache   查询缓存数据
 //未登录用户默认搜索和关键词搜索改成500条和免费用户保持一致--需求调整P260来自产品经理杨蘭20220116
-func (kws *KeyWordsSearch) GetBidSearchListByCache(in *bxcore.SearchReq) (list []*bxcore.SearchList, count int64) {
+func (kws *KeyWordsSearch) GetBidSearchListByCache(in *bxcore.SearchReq) (list []*bxcore.SearchList, count, total int64) {
 	//缓存数据 最大量是5000条  100页数据
 	l, c := func(in *bxcore.SearchReq) (list []*bxcore.SearchList, count int64) {
 		//缓存数据: SearchGroup-全部;招标信息;超前项目信息;kws.PageNum-当前页 免费用户 or 付费用户
@@ -61,10 +61,6 @@ func (kws *KeyWordsSearch) GetBidSearchListByCache(in *bxcore.SearchReq) (list [
 		kws.DefaultSearchParamsAuto(in)
 		//缓存数据
 		count, list = service.GetBidSearchData(in, true)
-		limitCount := int64(util.SearchPageSize * MC.If(in.IsPay, util.SearchMaxPageNum_PAYED, util.SearchMaxPageNum).(int))
-		if count > limitCount {
-			count = limitCount
-		}
 		if len(list) > 0 {
 			redis.Put(util.RedisNameNew, redisCountKey, count, MC.If(IC.C.DefaultSearchCacheTime > 0, IC.C.DefaultSearchCacheTime*60*60, 24*60*60).(int))
 			b, err := json.Marshal(list)
@@ -79,8 +75,13 @@ func (kws *KeyWordsSearch) GetBidSearchListByCache(in *bxcore.SearchReq) (list [
 		return
 	}(in)
 	if len(l) > 0 {
-		list = l[(in.PageNum-1)*in.PageSize : in.PageNum*in.PageSize]
+		total = c
+		limitCount := int64(util.SearchPageSize * MC.If(in.IsPay, util.SearchMaxPageNum_PAYED, util.SearchMaxPageNum).(int))
 		count = c
+		if count > limitCount {
+			count = limitCount
+		}
+		list = l[(in.PageNum-1)*in.PageSize : in.PageNum*in.PageSize]
 		//是否收藏
 		util.MakeCollection(in.UserId, list)
 	}

+ 0 - 1
jyBXCore/rpc/etc/bxcore.yaml

@@ -33,7 +33,6 @@ PaySearchLimit:
   PageSize: 20
 KeywordsLimit: 35 #主搜索框 关键词长度限制
 DefaultBidInfo: #默认搜索
-  Total: 180000000 #数据量提示
   PageNum: 10 #总页数
   Count: 500 #查询数据量
   PayCount: 5000 #付费用户查询数据量

+ 0 - 1
jyBXCore/rpc/internal/config/config.go

@@ -36,7 +36,6 @@ type Config struct {
 	} //优化付费用户搜索速度
 	KeywordsLimit  int //关键词长度限制
 	DefaultBidInfo struct {
-		Total    int64
 		PageNum  int
 		Count    int
 		PayCount int

+ 1 - 2
jyBXCore/rpc/internal/logic/getsearchlistlogic.go

@@ -43,7 +43,6 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 		Count:          0,
 		List:           []*bxcore.SearchList{},
 		InterceptLimit: int64(MC.IntAllDef(IC.C.KeywordsLimit, 35)),
-		Total:          MC.Int64All(IC.C.DefaultBidInfo.Total),
 	}
 	//初始化搜索对象
 	ks := entity.NewKeyWordsSearch()
@@ -51,7 +50,7 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 	heightWords := ks.SearchParamsHandle(in)
 	//判断是否是空搜索,如果是空搜索,查缓存数据
 	if ks.IsEmptySearch(in) {
-		res.List, res.Count = ks.GetBidSearchListByCache(in)
+		res.List, res.Count, res.Total = ks.GetBidSearchListByCache(in)
 		return &bxcore.SearchResp{
 			Data:    res,
 			ErrMsg:  "",