searchListLogic.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. logx.Info("++++++++++++++++:", req.KeyWords)
  30. res, err := l.svcCtx.BxCore.GetSearchList(l.ctx, &bxcore.SearchReq{
  31. AppId: req.AppId,
  32. UserId: req.UserId,
  33. Phone: req.Phone,
  34. NewUserId: req.NewUserId,
  35. EntId: req.EntId,
  36. EntUserId: req.EntUserId,
  37. PageNum: req.PageNum,
  38. PageSize: req.PageSize,
  39. Province: req.Province,
  40. City: req.City,
  41. Subtype: req.Subtype,
  42. TopType: req.TopType,
  43. PublishTime: req.PublishTime,
  44. SelectType: req.SelectType,
  45. Price: req.Price,
  46. Industry: req.Industry,
  47. BuyerClass: req.BuyerClass,
  48. BuyerTel: req.BuyerTel,
  49. WinnerTel: req.WinnerTel,
  50. FileExists: req.FileExists,
  51. SearchGroup: req.SearchGroup,
  52. SearchMode: req.SearchMode,
  53. WordsMode: req.WordsMode,
  54. KeyWords: req.KeyWords,
  55. AdditionalWords: req.AdditionalWords,
  56. ExclusionWords: req.ExclusionWords,
  57. UserType: req.UserType,
  58. Platform: util.CheckPlatform(l.r),
  59. BidField: req.BidField,
  60. })
  61. log.Println("请求接口耗时:", time.Since(t).Seconds())
  62. if err != nil {
  63. return &types.CommonResp{
  64. Err_code: res.ErrCode,
  65. Err_msg: res.ErrMsg,
  66. Data: nil,
  67. }, nil
  68. }
  69. return &types.CommonResp{
  70. Err_code: res.ErrCode,
  71. Err_msg: res.ErrMsg,
  72. Data: res.Data,
  73. }, nil
  74. }