package logic

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

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

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

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

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

func (l *SetReadLogic) SetRead(req *types.SetReadReq) (resp *types.CommonResp, err error) {
	// todo: add your logic here and delete this line
	res, err := l.svcCtx.Suscribe.SetRead(l.ctx, &bxsubscribe.SetReadReq{
		AppId:        req.AppId,
		UserType:     req.UserType,
		UserId:       req.UserId,
		NewUserId:    req.NewUserId,
		EntId:        req.EntId,
		IsEnt:        req.IsEnt,
		EntUserId:    req.EntUserId,
		Vsid:         req.Vsid,
		PositionType: req.PositionType,
	})
	if err != nil {
		return &types.CommonResp{
			Err_code: res.ErrorCode,
			Err_msg:  res.ErrorMsg,
			Data:     nil,
		}, nil
	}
	return &types.CommonResp{
		Err_code: res.ErrorCode,
		Err_msg:  res.ErrorMsg,
		Data:     nil,
	}, nil
	return
}
