muyu-apiserver/gateway/internal/svc/serviceContext.go

27 lines
853 B
Go
Raw Normal View History

package svc
import (
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
"muyu-apiserver/gateway/internal/config"
"muyu-apiserver/gateway/internal/middleware"
"muyu-apiserver/rpc/inventory/inventoryservice"
"muyu-apiserver/rpc/system/systemservice"
)
type ServiceContext struct {
Config config.Config
AuthorityMiddleware rest.Middleware
SystemRpc systemservice.SystemService
InventoryRpc inventoryservice.InventoryService
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
AuthorityMiddleware: middleware.NewAuthorityMiddleware().Handle,
SystemRpc: systemservice.NewSystemService(zrpc.MustNewClient(c.SystemRpc)),
InventoryRpc: inventoryservice.NewInventoryService(zrpc.MustNewClient(c.InventoryRpc)),
}
}