package logic

import (
	"context"
	"jyBXSubscribe/rpc/type/bxsubscribe"

	"jyBXSubscribe/api/internal/svc"
	"jyBXSubscribe/api/internal/types"

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

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

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

func (l *MsgDistributorLogic) MsgDistributor(req *types.MsgDistributor) (resp *types.CommonResp, err error) {
	res, err := l.svcCtx.Suscribe.MsgDistributor(l.ctx, &bxsubscribe.MsgDistributorReq{
		AppId:     req.AppId,
		EntId:     req.EntId,
		EntUserId: req.EntUserId,
		MessageId: req.MessageId,
		Staffs:    req.Staffs,
	})
	return &types.CommonResp{
		Err_code: res.ErrorCode,
		Err_msg:  res.ErrorMsg,
		Data:     res.Status,
	}, err
}
