// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2

package player

import (
	"context"
	"errors"
	"juwan-backend/app/player/rpc/playerservice"

	"juwan-backend/app/player/api/internal/svc"
	"juwan-backend/app/player/api/internal/types"

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

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

// 删除服务
func NewDeleteServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServiceLogic {
	return &DeleteServiceLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteServiceLogic) DeleteService(req *types.DeleteServiceReq) (resp *types.EmptyResp, err error) {
	_, err = l.svcCtx.PlayerRpc.DelPlayerServices(l.ctx, &playerservice.DelPlayerServicesReq{
		Id: req.Id,
	})
	if err != nil {
		logx.Errorf("DeleteServiceLogic.DeleteService err:%v", err)
		return nil, errors.New("failed to delete player service")
	}
	return
}
