buyerSearchListLogic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 BuyerSearchListLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. r *http.Request
  15. }
  16. func NewBuyerSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *BuyerSearchListLogic {
  17. return &BuyerSearchListLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. r: r,
  22. }
  23. }
  24. func (l *BuyerSearchListLogic) BuyerSearchList(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. BuyerName: req.BuyerName,
  34. Province: req.Province,
  35. City: req.City,
  36. BuyerClass: req.BuyerClass,
  37. IsCheckFollow: req.IsCheckFollow,
  38. IsCheckReceive: req.IsCheckReceive,
  39. UserType: req.UserType,
  40. UserId: l.r.Header.Get("userId"),
  41. EntId: req.EntId,
  42. EntUserId: req.EntUserId,
  43. PageSize: req.PageSize,
  44. PageNum: req.PageNum,
  45. IsContact: req.IsContact,
  46. })
  47. if err0 != nil {
  48. return &types.CommonResp{
  49. Err_code: -1,
  50. Err_msg: "错误",
  51. Data: nil,
  52. }, nil
  53. }
  54. return &types.CommonResp{
  55. Err_code: res.ErrCode,
  56. Err_msg: res.ErrMsg,
  57. Data: res.Data,
  58. }, nil
  59. }