package logic

import (
	"context"
	"github.com/gogf/gf/v2/util/gconv"
	"jyBXSubscribe/rpc/model"

	"jyBXSubscribe/rpc/internal/svc"
	"jyBXSubscribe/rpc/type/bxsubscribe"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetStaffSubscribeDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetStaffSubscribeDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStaffSubscribeDetailLogic {
	return &GetStaffSubscribeDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// GetStaffSubscribeDetail 查看企业员工用户订阅详情
func (l *GetStaffSubscribeDetailLogic) GetStaffSubscribeDetail(in *bxsubscribe.StaffSubscribeDetailReq) (*bxsubscribe.StaffSubscribeDetail, error) {
	rData, err := model.GetStaffSubscribeDetail(in.EntId, in.EntUserId, in.Token)
	if err != nil {
		return &bxsubscribe.StaffSubscribeDetail{
			ErrCode: -1,
			ErrMsg:  err.Error(),
			Data:    nil,
		}, nil
	}
	return &bxsubscribe.StaffSubscribeDetail{
		ErrCode: 0,
		ErrMsg:  "",
		Data:    gconv.Bytes(rData),
	}, nil
}
