getsearchlistlogic.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package logic
  2. import (
  3. MC "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/redis"
  5. "context"
  6. IC "jyBXCore/rpc/init"
  7. "jyBXCore/rpc/util"
  8. "strings"
  9. "jyBXCore/rpc/internal/svc"
  10. "jyBXCore/rpc/type/bxcore"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type GetSearchListLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewGetSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSearchListLogic {
  19. return &GetSearchListLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. // 标讯搜索结果列表数据
  26. func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.SearchResp, error) {
  27. defer MC.Catch()
  28. res := &bxcore.SearchResp{}
  29. if in.UserId != "" {
  30. //历史记录
  31. history_str := redis.GetStr("other", "s_"+in.UserId)
  32. arrs := util.SearchHistory(history_str, in.KeyWords)
  33. redis.Del("other", "s_"+in.UserId)
  34. redis.Put("other", "s_"+in.UserId, strings.Join(arrs, ","), -1)
  35. res.Data.HistoryKeys = arrs
  36. }
  37. //
  38. if in.SelectType == "" {
  39. in.SelectType = "title,content"
  40. }
  41. in.Industry = strings.TrimSpace(in.Industry)
  42. userInfo := util.GetVipState(IC.MainMysql, IC.Mgo, in.UserId)
  43. //付费用户
  44. if in.UserType != "fType" && !userInfo.IsPayedUser() {
  45. return &bxcore.SearchResp{
  46. ErrCode: -1,
  47. ErrMsg: "无权限",
  48. }, nil
  49. }
  50. //搜索范围
  51. queryItems := userInfo.GetQueryItems(in.SelectType, IC.C.BidSearchOldUserLimit)
  52. if in.UserType == "fType" {
  53. in.BuyerClass = ""
  54. in.BuyerTel = ""
  55. in.WinnerTel = ""
  56. in.ExclusionWords = ""
  57. in.City = ""
  58. }
  59. in.KeyWords = strings.TrimSpace(in.KeyWords)
  60. searchLimit := IC.IsSearchLimit(queryItems)
  61. in.SelectType = strings.Join(queryItems, ",")
  62. b_word, s_word := "", ""
  63. isLimit := 1
  64. if in.KeyWords != "" {
  65. b_word, _, s_word = util.InterceptSearchKW(in.KeyWords, false, len(in.Industry) == 0)
  66. }
  67. if in.KeyWords != "" || in.Industry != "" {
  68. //查询数据
  69. //全文检索限制
  70. if searchLimit {
  71. //limitFlag = public.Lst.Flag
  72. //isLimit = public.Lst.IsLimited(m.Request, m.ResponseWriter, m.Session(), isPayedUser)
  73. //if isLimit == 1 { //没有被限制
  74. // defer public.Lst.Limit()
  75. //}
  76. }
  77. if isLimit == 1 {
  78. util.SearchData()
  79. }
  80. }
  81. return &bxcore.SearchResp{}, nil
  82. }