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

package svc

import (
	"juwan-backend/app/player/rpc/playerservice"
	"juwan-backend/app/shop/api/internal/config"
	"juwan-backend/app/shop/rpc/shopservice"
	"juwan-backend/common/middlewares"

	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config                    config.Config
	ShopRpc                   shopservice.ShopService
	PlayerRpc                 playerservice.PlayerService
	HeaderExtractorMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:                    c,
		ShopRpc:                   shopservice.NewShopService(zrpc.MustNewClient(c.ShopRpcConf)),
		PlayerRpc:                 playerservice.NewPlayerService(zrpc.MustNewClient(c.PlayerRpcConf)),
		HeaderExtractorMiddleware: middlewares.NewHeaderExtractorMiddleware().Handle,
	}
}
