searchListLogic.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. }
  19. func NewSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *SearchListLogic {
  20. return &SearchListLogic{
  21. Logger: logx.WithContext(ctx),
  22. ctx: ctx,
  23. svcCtx: svcCtx,
  24. r: r,
  25. }
  26. }
  27. func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonResp, err error) {
  28. t := time.Now()
  29. res, err := l.svcCtx.BxCore.GetSearchList(l.ctx, &bxcore.SearchReq{
  30. PageNum: req.PageNum,
  31. PageSize: req.PageSize,
  32. PublishTime: req.PublishTime,
  33. Province: req.Province,
  34. City: req.City,
  35. Industry: req.Industry,
  36. BuyerClass: req.BuyerClass,
  37. KeyWords: req.KeyWords,
  38. Subtype: req.Subtype,
  39. SelectType: req.SelectType,
  40. Price: req.Price,
  41. FileExists: req.FileExists,
  42. BuyerTel: req.BuyerTel,
  43. WinnerTel: req.WinnerTel,
  44. ExclusionWords: req.ExclusionWords,
  45. AppId: req.AppId,
  46. UserType: req.UserType,
  47. SecondSearch: req.SecondSearch,
  48. UserId: l.r.Header.Get("userId"),
  49. EntId: l.r.Header.Get("entId"),
  50. Platform: util.CheckPlatform(l.r),
  51. })
  52. log.Println("请求接口耗时:", time.Since(t).Seconds())
  53. if err != nil {
  54. return &types.CommonResp{
  55. Err_code: res.ErrCode,
  56. Err_msg: res.ErrMsg,
  57. Data: nil,
  58. }, nil
  59. }
  60. return &types.CommonResp{
  61. Err_code: res.ErrCode,
  62. Err_msg: res.ErrMsg,
  63. Data: res.Data,
  64. }, nil
  65. }