searchListLogic.go 2.2 KB

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