12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package logic
- import (
- MC "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/redis"
- "context"
- IC "jyBXCore/rpc/init"
- "jyBXCore/rpc/util"
- "strings"
- "jyBXCore/rpc/internal/svc"
- "jyBXCore/rpc/type/bxcore"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type GetSearchListLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewGetSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSearchListLogic {
- return &GetSearchListLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 标讯搜索结果列表数据
- func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.SearchResp, error) {
- defer MC.Catch()
- res := &bxcore.SearchResp{}
- if in.UserId != "" {
- //历史记录
- history_str := redis.GetStr("other", "s_"+in.UserId)
- arrs := util.SearchHistory(history_str, in.KeyWords)
- redis.Del("other", "s_"+in.UserId)
- redis.Put("other", "s_"+in.UserId, strings.Join(arrs, ","), -1)
- res.Data.HistoryKeys = arrs
- }
- //
- if in.SelectType == "" {
- in.SelectType = "title,content"
- }
- in.Industry = strings.TrimSpace(in.Industry)
- userInfo := util.GetVipState(IC.MainMysql, IC.Mgo, in.UserId)
- //付费用户
- if in.UserType != "fType" && !userInfo.IsPayedUser() {
- return &bxcore.SearchResp{
- ErrCode: -1,
- ErrMsg: "无权限",
- }, nil
- }
- //搜索范围
- queryItems := userInfo.GetQueryItems(in.SelectType, IC.C.BidSearchOldUserLimit)
- if in.UserType == "fType" {
- in.BuyerClass = ""
- in.BuyerTel = ""
- in.WinnerTel = ""
- in.ExclusionWords = ""
- in.City = ""
- }
- in.KeyWords = strings.TrimSpace(in.KeyWords)
- searchLimit := IC.IsSearchLimit(queryItems)
- in.SelectType = strings.Join(queryItems, ",")
- b_word, s_word := "", ""
- isLimit := 1
- if in.KeyWords != "" {
- b_word, _, s_word = util.InterceptSearchKW(in.KeyWords, false, len(in.Industry) == 0)
- }
- if in.KeyWords != "" || in.Industry != "" {
- //查询数据
- //全文检索限制
- if searchLimit {
- //limitFlag = public.Lst.Flag
- //isLimit = public.Lst.IsLimited(m.Request, m.ResponseWriter, m.Session(), isPayedUser)
- //if isLimit == 1 { //没有被限制
- // defer public.Lst.Limit()
- //}
- }
- if isLimit == 1 {
- util.SearchData()
- }
- }
- return &bxcore.SearchResp{}, nil
- }
|