searchListLogic.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. BuyerName: req.BuyerName,
  34. Province: req.Province,
  35. City: req.City,
  36. BusinessScope: req.BusinessScope,
  37. Industry: req.Industry,
  38. BuyerClass: req.BuyerClass,
  39. IsCheckFollow: req.IsCheckFollow,
  40. IsCheckReceive: req.IsCheckReceive,
  41. UserType: req.UserType,
  42. UserId: l.r.Header.Get("userId"),
  43. EntId: req.EntId,
  44. EntUserId: req.EntUserId,
  45. Customer: req.Customer,
  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. return
  60. }