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

package player

import (
	"context"
	"juwan-backend/app/player/rpc/pb"

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

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

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

// 更新服务
func NewUpdateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateServiceLogic {
	return &UpdateServiceLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateServiceLogic) UpdateService(req *types.UpdateServiceReq) (resp *types.PlayerService, err error) {
	_, err = l.svcCtx.PlayerRpc.UpdatePlayerServices(l.ctx, &pb.UpdatePlayerServicesReq{
		Id:           req.Id,
		GameId:       req.GameId,
		Title:        req.Title,
		Description:  req.Description,
		Price:        req.Price,
		Unit:         req.Unit,
		RankRange:    req.RankRange,
		Availability: req.Availability,
	})
	if err != nil {
		return nil, err
	}
	return
}
