getstaffsubscribedetaillogic.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package logic
  2. import (
  3. "context"
  4. "encoding/json"
  5. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
  6. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/svc"
  7. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type GetStaffSubscribeDetailLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewGetStaffSubscribeDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStaffSubscribeDetailLogic {
  16. return &GetStaffSubscribeDetailLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *GetStaffSubscribeDetailLogic) GetStaffSubscribeDetail(req *types.GetStaffSubscribeDetailReq) (resp *types.StaffSubscribeCommonResp, err error) {
  23. res, err := l.svcCtx.Suscribe.GetStaffSubscribeDetail(l.ctx, &bxsubscribe.StaffSubscribeDetailReq{
  24. EntId: req.EntId,
  25. EntUserId: req.EntUserId,
  26. Token: req.Token,
  27. })
  28. if err != nil {
  29. return nil, err
  30. }
  31. if res.ErrCode != 0 {
  32. return &types.StaffSubscribeCommonResp{
  33. Err_code: res.ErrCode,
  34. Err_msg: res.ErrMsg,
  35. Data: nil,
  36. }, nil
  37. }
  38. subscribeDetail := map[string]interface{}{}
  39. if err := json.Unmarshal(res.Data, &subscribeDetail); err != nil {
  40. return &types.StaffSubscribeCommonResp{
  41. Err_code: res.ErrCode,
  42. Err_msg: "返回异常",
  43. Data: nil,
  44. }, nil
  45. }
  46. return &types.StaffSubscribeCommonResp{
  47. Err_code: res.ErrCode,
  48. Err_msg: res.ErrMsg,
  49. Data: subscribeDetail,
  50. }, nil
  51. }