searchListLogic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package logic
  2. import (
  3. "context"
  4. "jyBXBuyer/rpc/type/bxbuyer"
  5. "net/http"
  6. "jyBXBuyer/api/internal/svc"
  7. "jyBXBuyer/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type SearchListLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. r *http.Request
  15. }
  16. func NewSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *SearchListLogic {
  17. return &SearchListLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. r: r,
  22. }
  23. }
  24. func (l *SearchListLogic) SearchList(req *types.BuyerListReq) (resp *types.CommonResp, err error) {
  25. if req.EntUserId == "" {
  26. req.IsCheckReceive = false
  27. }
  28. if req.UserId == "" {
  29. req.IsCheckFollow = false
  30. }
  31. res, err0 := l.svcCtx.Buyer.BuyerList(l.ctx, &bxbuyer.BuyerListReq{
  32. AppId: req.AppId,
  33. PageNum: req.PageNum,
  34. PageSize: req.PageSize,
  35. BuyerName: req.BuyerName,
  36. Province: req.Province,
  37. City: req.City,
  38. BusinessScope: req.BusinessScope,
  39. SortRule: req.SortRule,
  40. Industry: req.Industry,
  41. BuyerClass: req.BuyerClass,
  42. IsCheckFollow: req.IsCheckFollow,
  43. IsCheckReceive: req.IsCheckReceive,
  44. UserType: req.UserType,
  45. UserId: l.r.Header.Get("userId"),
  46. EntId: req.EntId,
  47. EntUserId: req.EntUserId,
  48. })
  49. if err0 != nil {
  50. return &types.CommonResp{
  51. Err_code: -1,
  52. Err_msg: "错误",
  53. Data: nil,
  54. }, nil
  55. }
  56. return &types.CommonResp{
  57. Err_code: res.ErrCode,
  58. Err_msg: res.ErrMsg,
  59. Data: res.Data,
  60. }, nil
  61. return
  62. }