|
@@ -29,6 +29,7 @@ func NewGetSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// GetSearchList 标讯搜索结果列表数据
|
|
|
// GetSearchList 标讯搜索结果列表数据
|
|
|
func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.SearchResp, error) {
|
|
|
defer MC.Catch()
|
|
@@ -67,44 +68,13 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
|
|
|
t := time.Now()
|
|
|
//招标信息有效查询
|
|
|
res.IsLimit = 1
|
|
|
-<<<<<<< HEAD
|
|
|
- //以后可能会出现 关键词 C++ 等带+的关键词
|
|
|
- if in.KeyWords != "" {
|
|
|
- kwLimit := MC.IntAllDef(IC.C.KeywordsLimit, 35)
|
|
|
- if in.UserId == "" {
|
|
|
- kwLimit = 25
|
|
|
- }
|
|
|
- res.InterceptKeywords, res.InterceptWord, in.KeyWords = util.InterceptSearchKW(in.KeyWords, kwLimit, len(in.Industry) == 0)
|
|
|
- }
|
|
|
- if in.UserId == "" {
|
|
|
- //未登录用户访信息类型 需要过滤掉 拟建和采购意向问全部
|
|
|
- if in.Subtype == "" {
|
|
|
- in.Subtype = "招标预告,招标公告,招标结果,招标信用信息"
|
|
|
- }
|
|
|
- }
|
|
|
- //查询数据
|
|
|
- if in.KeyWords != "" || in.Industry != "" {
|
|
|
- //查询数据
|
|
|
- searchLimit := util.IsSearchLimit(strings.Split(in.SelectType, ","))
|
|
|
- //未登录用户标题、正文都限制,已登录用户只限制正文
|
|
|
- if in.UserId == "" {
|
|
|
- searchLimit = true
|
|
|
- }
|
|
|
- //全文检索限制
|
|
|
- if searchLimit {
|
|
|
- res.IsLimit = util.IsLimited(in.LimitFlag, in.UserId, in.UserType != "fType", in.IsNew)
|
|
|
- if res.IsLimit == 1 { //没有被限制
|
|
|
- defer util.Limit()
|
|
|
- }
|
|
|
-=======
|
|
|
//查询数据
|
|
|
searchLimit := util.IsSearchLimit(strings.Split(in.SelectType, ","))
|
|
|
//全文检索限制
|
|
|
if searchLimit {
|
|
|
- res.IsLimit = util.IsLimited(in.UserId, in.UserType != "fType")
|
|
|
+ res.IsLimit = util.IsLimited(in.LimitFlag, in.UserId, in.UserType != "fType", in.IsNew)
|
|
|
if res.IsLimit == 1 { //没有被限制
|
|
|
defer util.Limit()
|
|
|
->>>>>>> master
|
|
|
}
|
|
|
}
|
|
|
//无限制
|
|
@@ -122,115 +92,6 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
|
|
|
in.PublishTime = publishTime
|
|
|
res.Count, res.Total, res.List = ks.GetBidSearchList(in) //util.GetBidSearchData(in)
|
|
|
logx.Info("2查询耗时:", time.Since(t2))
|
|
|
-<<<<<<< HEAD
|
|
|
- res.KeyWords = in.KeyWords
|
|
|
- //二次搜索- 一次搜索结果少于一页数据;关键词长度大于三;第一,二页请求;搜索范围包括title;四个条件
|
|
|
- if len([]rune(in.KeyWords)) > 3 && int(count) < util.SearchPageSize && in.PageNum < 3 && strings.Contains(in.SelectType, "title") {
|
|
|
- if iksk := util.HttpEs(in.KeyWords, "ik_smart", IC.DB.Es.Addr); iksk != "" {
|
|
|
- t3 := time.Now()
|
|
|
- iksk_temp := in.KeyWords
|
|
|
- in.KeyWords = iksk
|
|
|
- in.SelectType = "title"
|
|
|
- //最多查两页数据
|
|
|
- in.PageSize = 2 * in.PageSize
|
|
|
- _, secondList := util.GetBidSearchData(in)
|
|
|
- //数据合并 去重 排序
|
|
|
- list = util.DelRepeatSearchData(list, secondList)
|
|
|
- count = int64(len(list))
|
|
|
- switch {
|
|
|
- case count > util.SearchPageSize:
|
|
|
- count = MC.If(count > int64(util.SearchPageSize*2), int64(util.SearchPageSize*2), count).(int64)
|
|
|
- list = list[:util.SearchPageSize]
|
|
|
- if in.SplitKeywords != "" {
|
|
|
- list = list[util.SearchPageSize:count]
|
|
|
- }
|
|
|
- case count <= util.SearchPageSize:
|
|
|
- list = list[:count]
|
|
|
- }
|
|
|
- var kbool = map[string]bool{}
|
|
|
- var karr = []string{}
|
|
|
- for _, v := range strings.Split(fmt.Sprintf("%s+%s", iksk_temp, iksk), "+") {
|
|
|
- if kbool[v] {
|
|
|
- continue
|
|
|
- }
|
|
|
- karr = append(karr, v)
|
|
|
- kbool[v] = true
|
|
|
- }
|
|
|
- //+&&& 作为二次搜索第二页数据请求的标识(临时处理)
|
|
|
- res.KeyWords = strings.Join(karr, "+") + "+&&&"
|
|
|
- logx.Info("3查询耗时:", time.Since(t3))
|
|
|
- }
|
|
|
- }
|
|
|
- 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 {
|
|
|
- count = limitCount
|
|
|
- }
|
|
|
- //是否收藏
|
|
|
- //util.MakeCollection(in.UserId, list)
|
|
|
- res.TotalPage = MC.If(in.PageNum == 1, (count+int64(util.SearchPageSize)-1)/int64(util.SearchPageSize), res.TotalPage).(int64)
|
|
|
- res.Count = count
|
|
|
- res.List = list
|
|
|
- }
|
|
|
- logx.Info("关键词 -0- 查询耗时:", time.Since(t).Seconds())
|
|
|
- } else if in.Platform == "PC" {
|
|
|
- var count int64 = 0
|
|
|
- var list = []*bxcore.SearchList{}
|
|
|
- redisDataKey := fmt.Sprintf("PC_SearchDataCache_%s_%d", in.Platform, in.PageNum)
|
|
|
- sCache, err := redis.GetNewBytes(util.RedisName, redisDataKey)
|
|
|
- if err == nil {
|
|
|
- redisCountKey := fmt.Sprintf("PC_SearchCountCache_%s", in.Platform)
|
|
|
- count = int64(redis.GetInt(util.RedisName, redisCountKey))
|
|
|
- if sCache != nil && len(*sCache) > 0 {
|
|
|
- err = json.Unmarshal(*sCache, &list)
|
|
|
- if err != nil {
|
|
|
- return &bxcore.SearchResp{
|
|
|
- ErrCode: -1,
|
|
|
- ErrMsg: "缓存数据序列化异常:" + err.Error(),
|
|
|
- }, nil
|
|
|
- }
|
|
|
- } else {
|
|
|
- pcstime := IC.C.PCSTime * 60 * 60
|
|
|
- //缓存数据
|
|
|
- _in := &bxcore.SearchReq{
|
|
|
- PageNum: in.PageNum,
|
|
|
- PageSize: in.PageSize,
|
|
|
- }
|
|
|
- count, list = util.SearchCahcheData(_in)
|
|
|
- limitCount := int64(util.SearchPageSize * util.SearchMaxPageNum)
|
|
|
- if in.UserId == "" {
|
|
|
- limitCount = util.SearchMaxPageCount_NOLOGIN
|
|
|
- }
|
|
|
- if count > limitCount {
|
|
|
- count = limitCount
|
|
|
- }
|
|
|
- if len(list) > 0 {
|
|
|
- redis.Put(util.RedisName, redisCountKey, count, pcstime)
|
|
|
- b, err := json.Marshal(list)
|
|
|
- if err == nil {
|
|
|
- redis.PutBytes(util.RedisName, redisDataKey, &b, pcstime)
|
|
|
- } else {
|
|
|
- return &bxcore.SearchResp{
|
|
|
- ErrCode: -1,
|
|
|
- ErrMsg: "缓存数据 转化异常:" + err.Error(),
|
|
|
- }, nil
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //是否收藏
|
|
|
- util.MakeCollection(in.UserId, list)
|
|
|
- res.TotalPage = MC.If(in.PageNum == 1, (count+int64(util.SearchPageSize)-1)/int64(util.SearchPageSize), res.TotalPage).(int64)
|
|
|
- res.Count = count
|
|
|
- res.List = list
|
|
|
- } else {
|
|
|
- return &bxcore.SearchResp{
|
|
|
- ErrCode: -1,
|
|
|
- ErrMsg: "查询redis缓存异常:" + err.Error(),
|
|
|
- }, nil
|
|
|
-=======
|
|
|
->>>>>>> master
|
|
|
}
|
|
|
res.KeyWords = strings.Join(heightWords, " ")
|
|
|
res.InterceptOtherWords = in.InterceptOtherWords
|