Bladeren bron

Merge branch 'feature/v1.1.12' of http://192.168.3.207:8080/BaseService/jyMicroservices into feature/v1.1.12

fuwencai 2 jaren geleden
bovenliggende
commit
86306b7381

+ 13 - 21
jyBXCore/rpc/entity/search.go

@@ -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())
 		}

+ 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:  "",

+ 2 - 0
jyBXCore/rpc/model/es/es.go

@@ -9,6 +9,7 @@ import (
 )
 
 const (
+	queryBoolMustTermDomain = `{"bool": {"must": [{ "term": {"bid_field": "%s" }}]}}` // 领域化数据类型
 	multiMatch              = `{"multi_match": {"query": "%s","type": "phrase", "fields": [%s]}}`
 	query                   = `{"query":{"bool":{"must":[%s],"must_not":[%s]}}}`
 	queryBoolShould         = `{"bool":{"should":[%s],"minimum_should_match": 1}}`
@@ -26,6 +27,7 @@ const (
 	BidSearchFieldBase      = `"_id","title","publishtime","dataweight","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass","spidercode","site"`                                                    //搜索列表基础字段
 	BidSearchFieldOfVip     = BidSearchFieldBase + `,"buyer","buyertel","buyerperson","agency","agencytel","agencyperson","s_winner","winnertel","winnerperson","signendtime","bidendtime","bidopentime","budget","projectinfo","entidlist"` //付费列表字段
 	BidSearchFieldFile      = `,"isValidFile"`                                                                                                                                                                                               //根据配置开关 选择是否显示 是否有附件提示,IC.C.FileSignBool
+	BidSearchDomainField    = BidSearchFieldOfVip + `,"purchasing"`                                                                                                                                                                          //领域数据字段基本字段
 	//DefaultFields       = `"title"`                                                                                                                                                                                                      //最新招标信息
 )
 

+ 4 - 0
jyBXCore/rpc/model/es/search.go

@@ -196,6 +196,10 @@ func GetSearchQuery(in *bxcore.SearchReq, mustQuery string) (qstr string) {
 			musts = append(musts, fmt.Sprintf(queryMissing, "isValidFile"))
 		}
 	}
+	// 如果是领域化数据则需要加标签
+	if in.BidField != "" {
+		musts = append(musts, fmt.Sprintf(queryBoolMustTermDomain, in.BidField))
+	}
 	qstr = fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(mustNot, ","))
 	logx.Info("qstr:", qstr)
 	return

+ 9 - 1
jyBXCore/rpc/service/search.go

@@ -19,13 +19,21 @@ func GetBidSearchData(in *bxcore.SearchReq, isCache bool) (count int64, list []*
 	if start >= 0 {
 		t := time.Now()
 		fields := MC.If(in.IsPay, es.BidSearchFieldOfVip, es.BidSearchFieldBase).(string)
+		//in.BidField(医疗)领域化字段
+		if in.BidField != "" {
+			fields = es.BidSearchDomainField
+		}
+		//IC.C.FileSignBool列表是否显示附件开关
+		if IC.C.FileSignBool {
+			fields = fields + es.BidSearchFieldFile
+		}
 		biddingSearch := es.SearchByES{
 			Index:      es.INDEX,
 			IType:      es.TYPE,
 			Query:      es.GetSearchQuery(in, es.GetBidSearchQuery(in)),
 			FindFields: MC.If(isCache, "title", "detail").(string),
 			Order:      es.BidSearchSort,
-			Fields:     MC.If(IC.C.FileSignBool, fields+es.BidSearchFieldFile, fields).(string), //IC.C.FileSignBool列表是否显示附件开关
+			Fields:     fields,
 			Start:      MC.If(isCache, 0, start).(int),
 			Limit:      MC.If(isCache, MC.If(in.IsPay, IC.C.DefaultBidInfo.PayCount, IC.C.DefaultBidInfo.Count).(int), int(in.PageSize)).(int),
 			Count:      MC.If(strings.Contains(in.SelectType, "detail"), 115, 0).(int),       //高亮正文数量

+ 0 - 5
jyBXCore/rpc/util/search.go

@@ -30,11 +30,6 @@ var (
 	filterReg  = regexp.MustCompile("^[的人号时元万公告项目地址电话邮编日期联系招标中结果成交项目项目采购采购项目政府采购公告更正公告]+$")
 	//PhoneReg     = regexp.MustCompile("^[1][3-9][0-9]{9}$")
 	//EmailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
-	// DomainPageType 缓存标签
-	DomainPageType = map[string]string{
-		"0101": "medical", // 医疗领域
-
-	}
 )
 
 // SearchHistory 格式化 关键词搜索历史记录