|
@@ -37,16 +37,16 @@ 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 付费用户
|
|
|
- redisDataKey := fmt.Sprintf(SearchCacheKey, in.SearchGroup, MC.If(in.IsPay, "v", "f").(string), MC.If(in.BidField != "", in.BidField, "n").(string))
|
|
|
- logx.Info("-------------------------redisDataKey--------------------------------:", redisDataKey)
|
|
|
//缓存数据总量 - 当前平台
|
|
|
redisCountKey := fmt.Sprintf(SearchCacheCount, in.SearchGroup, MC.If(in.IsPay, "v", "f").(string), MC.If(in.BidField != "", in.BidField, "n").(string))
|
|
|
- sCache, err := redis.GetNewBytes(util.RedisNameNew, redisDataKey)
|
|
|
count = int64(redis.GetInt(util.RedisNameNew, redisCountKey))
|
|
|
+ //缓存数据: SearchGroup-全部;招标信息;超前项目信息;kws.PageNum-当前页 免费用户 or 付费用户
|
|
|
+ redisDataKey := fmt.Sprintf(SearchCacheKey, in.SearchGroup, MC.If(in.IsPay, "v", "f").(string), MC.If(in.BidField != "", in.BidField, "n").(string))
|
|
|
+ sCache, err := redis.GetNewBytes(util.RedisNameNew, redisDataKey)
|
|
|
+ logx.Info("-------------------------redisDataKey--------------------------------:", redisDataKey)
|
|
|
if err == nil {
|
|
|
if sCache != nil && len(*sCache) > 0 {
|
|
|
err = json.Unmarshal(*sCache, &list)
|
|
@@ -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)
|
|
|
}
|
|
@@ -155,17 +156,8 @@ func (kws *KeyWordsSearch) GetSearchKeyWordsQueryStr(in *bxcore.SearchReq) (sear
|
|
|
func (kws *KeyWordsSearch) SearchParamsHandle(in *bxcore.SearchReq) []string {
|
|
|
//判断用户身份
|
|
|
userInfo := util.GetVipState(IC.MainMysql, IC.Mgo, in.UserId, in.EntId)
|
|
|
- userInfo.BigMember = 1
|
|
|
//是否是付费用户
|
|
|
in.IsPay = userInfo.IsPayedUser()
|
|
|
- // 医疗领域化数据
|
|
|
- if in.BidField != "" {
|
|
|
- if domainPageType, ok := util.DomainPageType[in.BidField]; ok {
|
|
|
- in.BidField = domainPageType
|
|
|
- } else {
|
|
|
- in.BidField = ""
|
|
|
- }
|
|
|
- }
|
|
|
//默认搜索范围
|
|
|
if in.SelectType == "" {
|
|
|
in.SelectType = "title,content"
|
|
@@ -196,8 +188,8 @@ func (kws *KeyWordsSearch) SearchParamsHandle(in *bxcore.SearchReq) []string {
|
|
|
}
|
|
|
//查询时间publishTime
|
|
|
if in.PublishTime == "" {
|
|
|
- //付费用户最新5年;免费用户最新3年
|
|
|
- in.PublishTime = fmt.Sprintf("%d-%d", time.Now().AddDate(-3, 0, 0).Unix(), time.Now().Unix())
|
|
|
+ //付费用户最新5年;免费用户||未登录用户最新1年
|
|
|
+ in.PublishTime = fmt.Sprintf("%d-%d", time.Now().AddDate(-1, 0, 0).Unix(), time.Now().Unix())
|
|
|
if userInfo.IsPayedUser() {
|
|
|
in.PublishTime = fmt.Sprintf("%d-%d", time.Now().AddDate(-5, 0, 0).Unix(), time.Now().Unix())
|
|
|
}
|