searchListLogic.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package logic
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "jyBXCore/api/internal/svc"
  6. "jyBXCore/api/internal/types"
  7. "jyBXCore/api/internal/util"
  8. "jyBXCore/rpc/type/bxcore"
  9. "log"
  10. "net/http"
  11. "time"
  12. )
  13. type SearchListLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. r *http.Request
  18. w http.ResponseWriter
  19. }
  20. func NewSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request, w http.ResponseWriter) *SearchListLogic {
  21. return &SearchListLogic{
  22. Logger: logx.WithContext(ctx),
  23. ctx: ctx,
  24. svcCtx: svcCtx,
  25. r: r,
  26. w: w,
  27. }
  28. }
  29. func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonResp, err error) {
  30. t := time.Now()
  31. <<<<<<< HEAD
  32. userid := l.r.Header.Get("userId")
  33. //未登录用户生成limitFlag
  34. limitFlag, isNew := util.GetFlag(l.r, l.w, userid)
  35. res, err1 := l.svcCtx.BxCore.GetSearchList(l.ctx, &bxcore.SearchReq{
  36. PageNum: req.PageNum,
  37. PageSize: req.PageSize,
  38. PublishTime: req.PublishTime,
  39. Province: req.Province,
  40. City: req.City,
  41. Industry: req.Industry,
  42. BuyerClass: req.BuyerClass,
  43. KeyWords: req.KeyWords,
  44. Subtype: req.Subtype,
  45. SelectType: req.SelectType,
  46. Price: req.Price,
  47. FileExists: req.FileExists,
  48. BuyerTel: req.BuyerTel,
  49. WinnerTel: req.WinnerTel,
  50. ExclusionWords: req.ExclusionWords,
  51. AppId: req.AppId,
  52. UserType: req.UserType,
  53. SplitKeywords: req.SplitKeywords,
  54. UserId: userid,
  55. EntId: l.r.Header.Get("entId"),
  56. Platform: util.CheckPlatform(l.r),
  57. Toptype: req.Toptype,
  58. LimitFlag: limitFlag,
  59. IsNew: isNew,
  60. =======
  61. res, err := l.svcCtx.BxCore.GetSearchList(l.ctx, &bxcore.SearchReq{
  62. AppId: req.AppId,
  63. UserId: req.UserId,
  64. Phone: req.Phone,
  65. NewUserId: req.NewUserId,
  66. EntId: req.EntId,
  67. EntUserId: req.EntUserId,
  68. PageNum: req.PageNum,
  69. PageSize: req.PageSize,
  70. Province: req.Province,
  71. City: req.City,
  72. Subtype: req.Subtype,
  73. TopType: req.TopType,
  74. PublishTime: req.PublishTime,
  75. SelectType: req.SelectType,
  76. Price: req.Price,
  77. Industry: req.Industry,
  78. BuyerClass: req.BuyerClass,
  79. BuyerTel: req.BuyerTel,
  80. WinnerTel: req.WinnerTel,
  81. FileExists: req.FileExists,
  82. SearchGroup: req.SearchGroup,
  83. SearchMode: req.SearchMode,
  84. WordsMode: req.WordsMode,
  85. KeyWords: req.KeyWords,
  86. AdditionalWords: req.AdditionalWords,
  87. ExclusionWords: req.ExclusionWords,
  88. UserType: req.UserType,
  89. Platform: util.CheckPlatform(l.r),
  90. BidField: req.BidField,
  91. >>>>>>> master
  92. })
  93. log.Println("请求接口耗时:", time.Since(t).Seconds())
  94. if err1 != nil {
  95. return &types.CommonResp{
  96. Err_code: res.ErrCode,
  97. Err_msg: res.ErrMsg,
  98. Data: nil,
  99. }, nil
  100. }
  101. return &types.CommonResp{
  102. Err_code: res.ErrCode,
  103. Err_msg: res.ErrMsg,
  104. Data: res.Data,
  105. }, nil
  106. }