searchListLogic.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. userid := l.r.Header.Get("userId")
  32. //未登录用户生成limitFlag
  33. limitFlag, isNew := util.GetFlag(l.r, l.w, userid)
  34. res, err1 := l.svcCtx.BxCore.GetSearchList(l.ctx, &bxcore.SearchReq{
  35. PageNum: req.PageNum,
  36. PageSize: req.PageSize,
  37. PublishTime: req.PublishTime,
  38. Province: req.Province,
  39. City: req.City,
  40. Industry: req.Industry,
  41. BuyerClass: req.BuyerClass,
  42. KeyWords: req.KeyWords,
  43. Subtype: req.Subtype,
  44. SelectType: req.SelectType,
  45. Price: req.Price,
  46. FileExists: req.FileExists,
  47. BuyerTel: req.BuyerTel,
  48. WinnerTel: req.WinnerTel,
  49. ExclusionWords: req.ExclusionWords,
  50. AppId: req.AppId,
  51. UserType: req.UserType,
  52. SplitKeywords: req.SplitKeywords,
  53. UserId: userid,
  54. EntId: l.r.Header.Get("entId"),
  55. Platform: util.CheckPlatform(l.r),
  56. Toptype: req.Toptype,
  57. LimitFlag: limitFlag,
  58. IsNew: isNew,
  59. })
  60. log.Println("请求接口耗时:", time.Since(t).Seconds())
  61. if err1 != nil {
  62. return &types.CommonResp{
  63. Err_code: res.ErrCode,
  64. Err_msg: res.ErrMsg,
  65. Data: nil,
  66. }, nil
  67. }
  68. return &types.CommonResp{
  69. Err_code: res.ErrCode,
  70. Err_msg: res.ErrMsg,
  71. Data: res.Data,
  72. }, nil
  73. }