package logic

import (
	"context"
	"errors"

	"juwan-backend/app/player/rpc/internal/svc"
	"juwan-backend/app/player/rpc/pb"

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

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

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

func (l *DelPlayerServicesLogic) DelPlayerServices(in *pb.DelPlayerServicesReq) (*pb.DelPlayerServicesResp, error) {
	err := l.svcCtx.PlayerModelRW.PlayerServices.DeleteOneID(in.Id).Exec(l.ctx)
	if err != nil {
		logx.Errorf("delete player services failed, %s", err.Error())
		return nil, errors.New("delete failed")
	}

	return &pb.DelPlayerServicesResp{}, nil
}
