distributorlogic.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package logic
  2. import (
  3. "context"
  4. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
  5. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/svc"
  6. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type DistributorLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DistributorLogic {
  15. return &DistributorLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *DistributorLogic) Distributor(req *types.DistributorReq) (resp *types.CommonResp, err error) {
  22. // todo: add your logic here and delete this line
  23. res, err := l.svcCtx.Suscribe.GetDistributor(l.ctx, &bxsubscribe.GetDistributorReq{
  24. AppId: req.AppId,
  25. EntId: req.EntId,
  26. EntUserId: req.EntUserId,
  27. Region: req.Region,
  28. QueryType: req.QueryType,
  29. })
  30. if err != nil {
  31. return &types.CommonResp{
  32. Err_code: res.ErrCode,
  33. Err_msg: res.ErrMsg,
  34. Data: nil,
  35. }, nil
  36. }
  37. var data []map[string]interface{}
  38. for _, v := range res.Items {
  39. _d := make(map[string]interface{})
  40. _d["name"] = v.Name
  41. _d["id"] = v.Id
  42. _d["phone"] = v.Phone
  43. data = append(data, _d)
  44. }
  45. return &types.CommonResp{
  46. Err_code: res.ErrCode,
  47. Err_msg: res.ErrMsg,
  48. Data: data,
  49. }, nil
  50. return
  51. }